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 |
|
Lambik
Starting Member
13 Posts |
Posted - 2010-05-07 : 05:01:27
|
| Hello,I have a table with values which are or upper case or lower case.When upper case I have to generate a Y when lower case i have to generate a N.when I run sql the result set is always lowHas anybody an idea?CREATE TABLE #TMP( [id] [varchar](10) NOT NULL, [Name] [varchar](50) NULL, [Initial] [varchar](5) NULL,) insert into #TMPselect '1','John','K'unionselect '2','Eric','L'unionselect '3','Geert','k'unionselect '4','Peter','a'unionselect '5','Andre','X'select * from #TMPselect cust.name, cust.initial, case (cust.initial) when lower(cust.initial) then 'low' when upper(cust.initial) then 'high' else 'X' End from dbo.#TMP cust |
|
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-05-07 : 05:06:56
|
| Hi this will help you i hopeselect cust.name, cust.initial, case when cust.initial COLLATE Latin1_General_CS_AS=upper(cust.initial) then 'high'else 'low'Endfrom dbo.#TMP custIam a slow walker but i never walk back |
 |
|
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-05-07 : 05:11:15
|
| Since your table is not case-sensitive u have to either use the collate for column in where condition where u want check for case-sensitivity or else alter table table1ALTER COLUMN Column1 VARCHAR(20)COLLATE Latin1_General_CS_AShope u understand the pointRefer thishttp://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/Iam a slow walker but i never walk back |
 |
|
|
Lambik
Starting Member
13 Posts |
Posted - 2010-05-07 : 05:22:14
|
| ok add collate gives me the right returnsthx again dineshrajanfrom the blog of Pinal Dave I understand that if you want to do a case sensitive search in a field you have to use collate. didn't knew that.Lambik |
 |
|
|
|
|
|
|
|