March 14, 2014 at 3:58 am
Hi there,
following is the base table
create table #sample (id int , value varchar(100))
insert into #sample values (1,'aaa,bbb')
insert into #sample values (2,'ccc,ddd')
insert into #sample values (3,'aab')
& i need the attached output
March 14, 2014 at 4:32 am
Take a look at this article from Jeff Moden. http://www.sqlservercentral.com/articles/Tally+Table/72993/
March 14, 2014 at 9:15 am
Hi,
HanShi is totally right.. After reading that article you'll end up with a query like the below:
DECLARE @Sample TABLE
(
Id INT,
Value VARCHAR(200)
)
INSERT INTO @Sample (Id,Value) VALUES (1,'aaa,bbb'),(2,'ccc,ddd'),(3,'aab')
SELECT s.Id, item.Item
FROM @Sample s
CROSS APPLY [dbo].[DelimitedSplit8K](value,',') [item]
Cheers,
Jim.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply