question

SQL_NewUser avatar image
SQL_NewUser asked

How to retreive one single value in comma separated columns form, from a table in sql server?

I have a table with values like the one below. I need to separate value number 10 from each row in SQL server.

The result I am looking for is a column with the values for C3 as in the second table. The table I have has more than 1,000 rows so this is just an example.

columnsvaluecomma separated
test.jpg (104.9 KiB)
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
ThomasRushton avatar image
ThomasRushton answered

Use a string splitter. Not the one that's built into modern versions of SQL Server, though, as that doesn't include an order / ordinal field so you can't guarantee which the 10th field is.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.