Split the column into rows.
Hi Boyan, The Column is comming from Database. in that column i am having firstname and last name Jeevan Dasari Jonathan Maharajan Raghu Patlola how can i give the condition for the database column value. if you any ideas please let me know. Dasari
December 13th, 2010 11:02pm

Does the column always look like, FirstName LastName FirstName LastName FirstName LastName or are there any exceptions, like FirstName MiddleName LastName FirstName LastName
Free Windows Admin Tool Kit Click here and download it now
December 13th, 2010 11:31pm

Hello Experts, I am having column which store Customer Name in SQL database as shown below Customer Name Jeevan Dasari Jonathan Maharajan Raghu Patlola the above column are the three names of customers having first name and last name with a space when stored in the column in the database. I want them like this Cutomer Name Jeevan Dasari Jonathan Maharajan Raghu Patlola I want them in one row only as shown below 1 Jeevan Dasari Jonathan Maharajan Raghu Patlola is it possible in SQL using functions or Reporting Services. note it's not having any commas to use delimter function. can any help me out. DasariDasari
December 13th, 2010 11:53pm

If it is FN1 LN1 FN2 LN2...you can do something like DECLARE @lstr varchar(100); DECLARE @ix int; SET @lstr = 'fn1 ln1 fn2 ln2 fn3 ln3'; SET @ix = 1; WHILE @ix < LEN(@lstr) BEGIN SELECT SUBSTRING(@lstr, @ix, CHARINDEX(' ', @lstr, CHARINDEX(' ', @lstr)+1)); SET @ix = @ix + CHARINDEX(' ', @lstr, CHARINDEX(' ', @lstr)+1); END This will split the column into rows - if that's what you want to achieve. Otherwise, to add a line break in SSRS you could code it like this: DECLARE @lstr varchar(100); DECLARE @ix int; DECLARE @retStr varchar(100); SET @lstr = 'fn1 ln1 fn2 ln2 fn3 ln3'; SET @ix = 1; SET @retStr = ''; WHILE @ix < LEN(@lstr) BEGIN SET @retStr = @retStr + SUBSTRING(@lstr, @ix, CHARINDEX(' ', @lstr, CHARINDEX(' ', @lstr)+1)) + CHAR(10); SET @ix = @ix + CHARINDEX(' ', @lstr, CHARINDEX(' ', @lstr)+1); END SELECT @retStr; If you place the output in one cell it will get split with carriage return character. Of course, in both examples you will have to change the code to use your column instead of the @lstr variable, together with adding FROM clauses where necessary. Boyan Penev --- http://www.bp-msbi.com
Free Windows Admin Tool Kit Click here and download it now
December 14th, 2010 12:13am

Hi Dasari, You can use vbcrlf as a new line symbol in SSRS. E.g.: ="Line 1" + vbcrlf + "Line 2" There is more info here: http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/1d8239bd-2a95-4109-84bf-6212faa13049 Also, for a database break: http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/d3d48dcb-84d6-4d2f-b597-c1a9a291aad2 And with code: http://www.kodyaz.com/articles/reporting-services-add-line-break-between-words-custom-code.aspx Boyan Penev --- http://www.bp-msbi.com
December 14th, 2010 12:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics