Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
SQL server 7
Database 6
Tips 5
Tricks 5
#SQLServer 3
Backup 2
MSSQL 1
'E0' 1
isnumeric 1
Issues 1

Archive · View All
December 2011 4
March 2012 2
January 2012 1

Raghunath Bhandari's Blog

Table Row data in String

Dec 21 2011 10:08PM by Raghunath Bhandari   

We can use this script to show the row data in string.


Name
------
RAM
SHYAM
HARI RITA
Name
RAM,SHYAM,HARI,RITA

--Use the following query DECLARE @strList varchar(100)
SELECT @strList = COALESCE(@strList + ', ', '') +   CAST(Name AS varchar(5))
FROM TABLE1

SELECT @strList

Tags: Database, SQL server, Tricks, Tips, Table Row in String, #SQLServer,


Raghunath Bhandari
183 · 1% · 253
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • You can do the same with this script as well:

    SELECT ISNULL(STUFF((SELECT ',' +  Name FROM Table1 FOR XML PATH('')), 1, 1, ''), '')
    
    commented on Jan 12 2012 11:09PM
    Olga Medvedeva
    66 · 3% · 843
  • This can also be represented as:

    DECLARE @strList varchar(max)= ''

    SELECT @strList += COALESCE(CAST(Name as varchar(5) + ', ', '') FROM TABLE1

    SELECT LEFT(@strList, LEN(@strList) - 1)

    A few problems with your approach: If the rows add up to more than 100 characters, you'll get either truncation or an overflow error. If any of them contain NULL, the resulting string will be NULL. In your example, there would also be a trailing comma.

    commented on Jan 15 2012 11:33AM
    Marc Jellinek
    97 · 2% · 545

Your Comment


Sign Up or Login to post a comment.

"Table Row data in String" rated 5 out of 5 by 1 readers
Table Row data in String , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]