have a table tb, follows: id value


1 aa,bb

2 aaa,bbb,ccc

Split the value column by id, and the results are as follows:

id value


1 aa

1 bb

2 aaa

2 bbb

2 ccc

*/

create table tb(id int,value varchar(30))

insert into tb values(1,'aa,bb')

insert into tb values(2,'aaa,bbb,ccc')

go

thanks!

asked 16 Apr, 07:51

mfkpie8's gravatar image

mfkpie8
80465054
accept rate: 9%

2

What have you tried so far?

(16 Apr, 07:58) Justin Willey
Replies hidden

Oops, I overlooked that important comment:(

(16 Apr, 08:09) Volker Barth

I'm not sure I understand your question but I guess you are asking for

select tb.id, sp.row_value
from tb cross apply sa_split_list(tb.value, ',') sp
order by 1, 2
permanent link

answered 16 Apr, 08:07

Volker%20Barth's gravatar image

Volker Barth
33.8k330486716
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×430

question asked: 16 Apr, 07:51

question was seen: 113 times

last updated: 16 Apr, 08:09