select STUFF((SELECT N';' + TableColumnName
FROM dbo.SrcTableName
FOR XML PATH(''), TYPE).value('.[1]', 'nvarchar(max)'), 1, 2, N'')
Or:
declare @StrList nvarchar(max) = ''
update dbo.SrcTableName
set @StrList = @StrList+ isnull(TableColumnName, '') + ','
select @StrList=left(@StrList,len(@ StrList)-1)
select @StrList
No comments:
Post a Comment