sql server - how to separate comma in SQL -


i data field:

maritalstatus=m;youngest=[-0.999,0.999]; 

split to:

field name = maritalstatus , data m  field name = youngest , data [-0.999,0.999];  

how write sql?

that's bit of fun substring , charindex it's doable 2 pieces of information extract:

select substring(@string,             charindex('=', @string) + 1,             charindex(';', @string) - charindex('=', @string) - 1) maritalstatus,        substring(@string,             charindex('=', @string, charindex(';', @string)) + 1,             len(@string) - charindex('=', @string, charindex(';', @string))) youngest  

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -