There are situations where you need the resultant values of a single column to be displayed/processed as a single string. So here goes the query:
DECLARE @Str VARCHAR(MAX)
SELECT @Str = COALESCE(@Str+',' ,'') + CONVERT(varchar,Column1) FROM MyTable
SELECT @Str
DECLARE @Str VARCHAR(MAX)
SELECT @Str = COALESCE(@Str+',' ,'') + CONVERT(varchar,Column1) FROM MyTable
SELECT @Str
No comments:
Post a Comment