I need some info.
I have written a query which was working fine with DB user id and password deticated to this DB which i am using.
Then we change the login mode to Windows Login with Trusted connection. After this change my query is failing.
My query is which working in SQL login mode is
SELECT DATE_TIME,CARDNO, NATIONALID, DOB, STATUS FROM TBL_INFO where DATE_TIME between '29/12/2003 00:00:01' and '30/12/2003 23:59:59' Order by DATE_TIME ASC
Where DATE_TIME is date time Data type.
i change this query to check with Windows login with trusted connection.
SELECT DATE_TIME,CARDNO, NATIONALID, DOB, STATUS FROM TBL_INFO where DATE_TIME between convert(datetime, '29/12/2003', 103 ) and convert(datetime, '30/12/2003', 103 ) Order by DATE_TIME ASC
No Error is mention for this query but no records are fetched. But data is there in DB.
Please help i am new to SQL server.
Expecting your replies ASAP
Originally posted by rnealejr
Has the windows login been given access to the database/tables ? Where are you running these queries ? Do you have access to query analyzer ?
Yes i have access to Tables. i have been given DB owner rights.
i have to run these queries form Visual basic. i have to populate these data as reports using Crystal reports. Query is not working even in Query Analyser.
i ma trying it out with 2 diff login id with query analyser
Originally posted by blindman
You seem to be focusing on the fact that you changed your login method, but your post indicates that you also changed your query, and this is likely the problem. For one thing,
between '29/12/2003 00:00:01' and '30/12/2003 23:59:59'
is NOT the same as
between convert(datetime, '29/12/2003', 103 ) and convert(datetime, '30/12/2003', 103 )
At the very least, the second statement covers 24 fewer hours than the first statement, so any data on 30/12/2003 would not show up.
Why did you switch to using a convert function?
As my Previous Query was not working under Trusted conenction it throws me error stating that "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
So to solve this i tired with Convert fucntion. Still after that no records are fetched. But data is there in Table.