Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

How to get value based on position of special character string in a column

$
0
0
I have a table like this [quote]Col1 Col2Adam 1Barbara, Catherina 1Barbara, Catherina 2Adam, Catherina 1Adam, Catherina 2Barbara, Adam, Daniela 1Barbara, Adam, Daniela 2Barbara, Adam, Daniela 3[/quote]Need a select statement to populate Col3 like shown below[quote]Col1 Col2 Col 3Adam 1 AdamBarbara, Catherina 1 BarbaraBarbara, Catherina 2 CatherinaAdam, Catherina 1 AdamAdam, Catherina 2 CatherinaBarbara, Adam, Daniela 1 BarbaraBarbara, Adam, Daniela 2 AdamBarbara, Adam, Daniela 3 Daniela[/quote]I tried using SUBSTRING & CHARINDEX but was not able to fid the solution. Need a SQL where we can pass Col2 value and populate Col3.Uploaded the sample table as attachment.Please help.Thank you, Vikram

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images