sql server - Test for Upper Case - T-Sql -
all,
how can check if specified varchar character or entire string upper case in t-sql? ideally i'd write function test if character upper case, can later apply generic varchar. should return false non alphabetic characters. interested in english language characters.
i working t-sql in sql management studio, , have tried pulling records beginning lower case letter table in fashion:
select * table substring(author,1,1) != lower(substring(author,1,1))
which returns 0 records, know there records beginning upper , lower case letters.
thanks
edit: since both podiluska , joachim-isaksoon have answered question (both methods work purposes), mind explaining efficient method use query table large number of records filter out records authors beginning or without capital letter?
using collations
eg:
if ('a'='a' collate latin1_general_ci_ai) print'same 1' else print 'different 1' if ('a'='a' collate latin1_general_cs_ai) print'same 2' else print 'different 2'
the cs in collation name indicates case sensitive (and ci, case insensitive). ai/as relates accent sensitivity.
or in example
substring(author,1,1) <> lower(substring(author,1,1)) collate latin1_general_cs_ai
Comments
Post a Comment