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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 CASE SUBSTRING

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-03-20 : 21:15:09
I would like to find the last 5 characters on a column based upon a join I wrote. when it finds anything that matches the word "color" WHICH is 5 characters long it should rename it to "color". else "b&W". So the table may have a column name "print monitor color" or fax copier.


CASE SUBSTRING(left(me.name , 5) = "color" then "color" else "B&W"))
END

is this correct



khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-20 : 23:49:13
[code]CASE WHEN RIGHT(me.name , 5) = 'color' then 'color' else 'B&W' END[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -