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 2012 Forums
 Transact-SQL (2012)
 Patten matching in case statement

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2015-01-11 : 11:00:25
I have a column A that has values like C123
,C345_1,C34_2, I added a new coulmn B that looks up the value in A and assigns G ,S,M

Basically any value matching patterns,####_1, ###_# (C34_2 ,C346_1)then assign a value of M
Any value matching pattern ####,###(C123,C23) that doesn't have and child example c345 then c345_1, c345_ ...... etc ,then assign a value S

If I have let's say c345 then I have c345_1,c345_2. And so on. I want to assign a G to C345 because it is the parent then still assign C345_1 ,C345_2 which are the child a value of M

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-11 : 12:51:13
play with PATINDEX to build and test pattern matching. Post what you come up with
Go to Top of Page
   

- Advertisement -