SQL Query in QA -vs- VS

J

jp2msft

Is there a limit to the string length for sending SQL queries to the SQL
Server in Visual Studio 2005 Professional?

I have a query that I can run in VS using an SqlDataAdapter, and it returns
0 rows.

If I paste this same query into Query Analyzer, it returns 7016 rows.

VS and QA are using the same SQL Server, same tables, etc.

I have other queries in VS using the same SQL Server (i.e. same connection
string), and these DataTables fill just fine.

There is no error; the query just returns 0 rows.

Here is the query, and this is the exact string that I pass to the SQL
Server from VS:

SELECT TR.[OP_ID], EI.[NUM], TR.[Date_Time]
FROM Test_Results TR LEFT JOIN EmployeeInfo EI ON OP_ID=EI.[FIRSTNAME]+'
'+EI.[LASTNAME]
WHERE
(TR.[System_ID] Like '%Decay%') AND
(EI.[JOBTITLE]='BRZ OPRTR') AND
(EI.[NUM] IS NOT NULL) AND
('7/1/2008' < TR.[Date_Time]) AND
(TR.[Date_Time] < '7/31/2008')
ORDER BY OP_ID, TR.[Date_Time]

Is this too long of a string to pass through VS?

How can I debug this?
 
M

Mr. Arnold

jp2msft said:
Is there a limit to the string length for sending SQL queries to the SQL
Server in Visual Studio 2005 Professional?

I have a query that I can run in VS using an SqlDataAdapter, and it
returns
0 rows.

If I paste this same query into Query Analyzer, it returns 7016 rows.

VS and QA are using the same SQL Server, same tables, etc.

I have other queries in VS using the same SQL Server (i.e. same connection
string), and these DataTables fill just fine.

There is no error; the query just returns 0 rows.

Here is the query, and this is the exact string that I pass to the SQL
Server from VS:

SELECT TR.[OP_ID], EI.[NUM], TR.[Date_Time]
FROM Test_Results TR LEFT JOIN EmployeeInfo EI ON OP_ID=EI.[FIRSTNAME]+'
'+EI.[LASTNAME]
WHERE
(TR.[System_ID] Like '%Decay%') AND
(EI.[JOBTITLE]='BRZ OPRTR') AND
(EI.[NUM] IS NOT NULL) AND
('7/1/2008' < TR.[Date_Time]) AND
(TR.[Date_Time] < '7/31/2008')
ORDER BY OP_ID, TR.[Date_Time]

Is this too long of a string to pass through VS?
No

How can I debug this?

I don't know what to tell you. I guess you'll hit upon what is wrong sooner
or later.
 
M

Marc Gravell

Is this too long of a string to pass through VS?

No - that is a very short TSQL string; my first thought was "different
SET options" (on particular ANSI NULLS), but you seem to be using fairly
standard TSQL. The line-ending worries me a little - you might want to
look at whether this is getting normalized in some way (breaking it).

The other classic thing to check is: do you have your own copy of the
data - i.e. are you hitting Foo.Test_Results with one query, and
Bar.Test_Results with the other (where Foo and Bar are logins / schemas).

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top