create procedure Dlist
@table varchar(200),
@column varchar(200)
as
declare @strSQL nvarchar(2000)
declare @params nvarchar(2000)
declare @x1 nvarchar(2000)
set @strSQL = 'select @x = coalesce(@x + '','', '''') + cast(' + @column + ' as varchar) from ' + @table
set @params = N'@x varchar(2000) OUTPUT'
exec sp_executeSQL @strSQL, @params, @x = @x1 OUTPUT
select @x1
|