September 27, 2010 at 9:54 am
Can anyone help me with this?
I have a table with an ID, last name, and first name which are all varchar. There are other columns in the table also.
My table looks like this:
ID Lastname Firstname
12345 Smith Robert
12346 Smith Robert
12347 Smith Robert
If I query the table where ID = 12345, I get the record for Robert Smith.
If I query the table where lastname = 'Smith' and Firstname = 'Robert', I get some Robert Smith records, but not 12345 which I am looking for? Someone had suggested to me to drop the indexes on that table and recreate them, but that did not change anything.
Thanks.
October 3, 2010 at 10:31 am
Kevin Wieand (9/27/2010)
Can anyone help me with this?I have a table with an ID, last name, and first name which are all varchar. There are other columns in the table also.
My table looks like this:
ID Lastname Firstname
12345 Smith Robert
12346 Smith Robert
12347 Smith Robert
If I query the table where ID = 12345, I get the record for Robert Smith.
If I query the table where lastname = 'Smith' and Firstname = 'Robert', I get some Robert Smith records, but not 12345 which I am looking for? Someone had suggested to me to drop the indexes on that table and recreate them, but that did not change anything.
Thanks.
Is it case sensitive ? What is the server and db collation set to ? Version of sql server ?
Cheers !
______________________________________________________________________________________________________________________________________________________________________________________
HTH !
Kin
MCTS : 2005, 2008
Active SQL Server Community Contributor 🙂
October 3, 2010 at 10:43 am
Have you checked for spaces in the names?
Have you tried to run your query with a like operator rather than an equality operator?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
October 5, 2010 at 9:02 pm
What happens when you query the table with where Ltrim(Rtrim(lastname)) = 'Smith' and Ltrim(Rtrim(Firstname)) = 'Robert'?
October 15, 2010 at 5:45 pm
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply