Quick Search

Bind multiple rows value in a single row

February 27th, 2010 by admin
Leave a reply »

 

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

Posted in Database

You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.

Leave a Reply