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 |
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2010-07-09 : 13:02:42
|
I am trying to write a case statement which will display '00000' where the FIRST character of the column is an ALPHA character.Also, when the column is NULL, it will display '00000' Select Test = CASE c.a_column WHEN isnull THEN '00000' WHEN isalpha THEN '00000' ELSE c.a_columnENDFrom TestTableThanks |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-07-09 : 13:16:44
|
when you say ALPHA you mean [a-z] or could it also include é types<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-07-09 : 13:21:10
|
case when SUBSTRING(column,1,1)like '%[a-z]' then .... else .... endLimitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-09 : 13:23:33
|
quote: Originally posted by Idera case when SUBSTRING(isnull(column,'a'),1,1)like '%[a-z]' then .... else .... endLimitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-07-09 : 13:29:01
|
CASE WHEN LEFT(column,1) COLLATE Latin1_General_CS_AS LIKE '[a-z]' THEN '00000'<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-09 : 13:31:37
|
quote: Originally posted by yosiasz CASE WHEN LEFT(isnull(column,'a'),1) COLLATE Latin1_General_CS_AS LIKE '[a-z]' THEN '00000'<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|