sql server - Displaying multiple values from same column in one row in SQL -
i'm working on stored procedure, extend 1 function here on job. @ moment have problem in displaying multiple values same column in 1 row, , have differed , presented 25,26,27
so i've been trying.
declare @myvariable varhcar(200) null) select @myvariable = coalesce(@myvariable + '','','') + stringvalue table column1 = somevariable , issue = column2 select @headtext = 'name' + convert(varchar, @myvariable)
before in sp create table, displays other data. want sp create rows data aswell. still got troubles not sure have this, first timer kind of sp.
your code should like:
declare @myvariable varhcar(200); select @myvariable = coalesce(@myvariable + ',', '') + stringvalue table column1 = somevariable , issue = column2; select @headtext = 'name' + @myvariable;
another way concatenate variables is:
select @myvariable = stuff((select ',' + stringvalue table column1 = somevariable , issue = column2 xml path ('') ), 1, 1, ''); select @headtext = 'name' + @myvariable;
Comments
Post a Comment