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.
Author |
Topic |
mohdrashid
Starting Member
23 Posts |
Posted - 2005-06-02 : 05:40:54
|
hi,if i have the following records:col1abcAbcaBcabCABCdoing a select with a where col1 = 'abC' will return me all the rows in the above table.I would like it to return only the fourth row.how to do this?thanks in advancerashid |
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-06-02 : 06:49:34
|
You could change the collation of the column to Case SensitiveExample:CREATE TABLE #MyTemp(Col1 varchar(3)) --Using My Default CollationGOINSERT #MyTemp(Col1)SELECT 'abc' UNION ALLSELECT 'Abc' UNION ALLSELECT 'aBc' UNION ALLSELECT 'abC' UNION ALLSELECT 'ABC'GOSELECT *FROM #MyTempWHERE Col1 = 'abC' --All records will be returnedGOALTER TABLE #MyTemp ALTER COLUMN Col1 varchar(3)COLLATE Latin1_General_CS_AS --CS bit = Case SensitiveGOSELECT *FROM #MyTempWHERE Col1 = 'abC' --Only 1 record this timeGODROP TABLE #MyTemp AndyBeauty is in the eyes of the beerholder |
|
|
|
|
|