create table tbl_name(Name varchar(20))
insert into tbl_name values('adi')
insert into tbl_name values('jc')
insert into tbl_name values('ravi')
insert into tbl_name values('raghu')
DECLARE @name_list VARCHAR(MAX)
SELECT @name_list = COALESCE(@name_list+',' ,'') + Name from tbl_name
SELECT @name_list
OUTPUT
adi,jc,ravi,raghu
insert into tbl_name values('adi')
insert into tbl_name values('jc')
insert into tbl_name values('ravi')
insert into tbl_name values('raghu')
DECLARE @name_list VARCHAR(MAX)
SELECT @name_list = COALESCE(@name_list+',' ,'') + Name from tbl_name
SELECT @name_list
OUTPUT
adi,jc,ravi,raghu
No comments:
Post a Comment