Microsoft SSIS and Sql Server Notes
Monday, March 19, 2012
Create Comma Separated List- Sql tips and tricks
Create list of Integer type column
[code]
DECLARE @listStr VARCHAR(MAX)
SELECT @listStr = COALESCE(@listStr+',' ,'') + CAST(ColumnName AS Varchar(10))
FROM TableName
SELECT @listStr
GO
[/code]
Replace
ColumnName
and
TableName
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment