sql server 2008 - Get a value in a single cell into multiple rows using SSRS -
sql server 2008 - Get a value in a single cell into multiple rows using SSRS -
one particular field in sql table has value in below format.
value11,value12,value13
value21,value22,value23
...
...
i need each of above lines in text individual lines using ssrs. illustration 2 rows in study above data. there way using reporting project in vs or study builder?
thanks in advance.
update
hi,below ddl table
tbltest
[id] int
[description] varchar(max)
lets assume there 1 record below
insert tbltest ([id],[description]) values (1, 'value11,value12,value13
value21,value22,value23')
so there carriage homecoming caharacter in above insert description column. have 2 lines in description row.
so requirement when retrieve data, should below format.
id, description
1, value11,value12,value13
1, value21,value22,value23
you can utilize select
passing info reporting services
.
select t1.id, t2.splitteddescriptions ( select tbltest.id, cast('<row>' + replace(tbltest.[description], char(13) + char(10), '</row><row>') + '</row>' xml) xmlrow tbltest ) t1 cross apply ( select xmltable.splittedrow.value('.', 'varchar(max)') splitteddescriptions t1.xmlrow.nodes('/row') xmltable(splittedrow) ) t2
it uses xml
, nodes()
method split description when finds crlf
.
it work single crlf
, if need work double crlf
can modify select
.
example - input data:
insert tbltest ([id],[description]) values (1, 'val11, val12, val13' + char(13) + char(10) + 'val21, val22, val23') insert tbltest ([id],[description]) values (2, 'val31, val32, val33') insert tbltest ([id],[description]) values (3, 'val41, val42, val43' + char(13) + char(10) + 'val51, val52, val53' + char(13) + char(10) + 'val61, val62, val63')
example - output:
id splitteddescriptions ----------- -------------------- 1 val11, val12, val13 1 val21, val22, val23 2 val31, val32, val33 3 val41, val42, val43 3 val51, val52, val53 3 val61, val62, val63
sql-server-2008 reporting-services ssrs-2008-r2
Comments
Post a Comment