Use a select statement to create a list within a varchar variable
This code example demonstrates Sql programming techniques and best practices.
create table #demo (ID varchar(8))
insert into #demo (ID) values (1),(2), (3), (4)
DECLARE @cols NVARCHAR(max) = '';
SELECT @cols = (@cols + ',' + ID) FROM #demo fs
select @cols
Language: Sql
Original Source: BlogEngine.NET Migration
Code Lines: 31
Select a list into a variable.
SQL array to list.
Use a select statement to create a list within a varchar variable
Select a list into a variable. SQL array to list. create table #demo (ID varchar(8)) ins