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
 How to fetch values from table igorning case?

Author  Topic 

sqlontherun101
Starting Member

16 Posts

Posted - 2009-08-28 : 03:44:33
Hi,

I have the followin select statement:

select count(*) Customer where fName = @Name

How do i modify the select statement to fecth teh number of rows with the name in @Name ignoring upper and lower case.

there could be two entry such as

Assume @Name value is "ruby" and if the data base has two rows one wiht "ruby" and the other with "Ruby", they row count should return as 2. How do i modify the above Query do the above?

cheers


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-28 : 04:04:37
select count(*) from Customer where lower(fName) = lower(@Name)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-08-28 : 04:05:18
What is the collation of the fName column?

Try using a case-sensitive or binary collation. Example:
SELECT count(*) FROM Customer WHERE fName COLLATE Latin1_General_BIN = 'ruby'
Go to Top of Page
   

- Advertisement -