Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Existing data missing in result set

Author  Topic 

Jake Shelton
Yak Posting Veteran

74 Posts

Posted - 2012-02-06 : 07:49:54
Hi all, when I run the following (note the commented out code) I get several

Select *
From Ledger
--Where user ='Peggy'

This returns 1 row containing the word 'Peggy'. However, when I run

Select *
From Ledger
Where user ='Peggy'

the query returns zero rows. I get a feeling this behaviour is connected with the user column being ambiguous, any ideas?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-06 : 08:09:48
It could be that there are no rows where user is Peggy. It also could be that there are spaces preceding or after the name - you can test for that by using the where clause as:

WHERE
ltrim(rtrim(user)) = 'Peggy'
If that doesn't help, find some users that do exist - for example:
SELECT TOP 10 * from Ledger
That would give you the top 10 rows. Pick a user you see in there and put in the where clause of your query to see if that works.
Go to Top of Page
   

- Advertisement -