Bind multiple rows value in a single row
Following example demonstrate that how you can bind multiple rows value in a single row. Through this query you got comma (,) separated value in a single row.
Example:-
declare @a varchar(500)
set @a = ‘ ‘
select @a = @a + cast(id as varchar(20)) + ‘,’ from dbo.TR_UserBasic
if len(@a)>1
set @a= left(@a,len(@a)-1)
select case @a when ” then ’0′ else @a end as id
Out Put- 110,111,112,113,130,93,104,95,96,97,98,99,100,101,102,103