hi,
i have a table called names and field name
select * from names
name
a
b
c
d

i want to display like this
name
a,b,c,d
how it is possible


Regards
Baiju

Answer Posted / prasanna

create procedure loopcure
as
BEGIN
declare @a int, @b varchar(020), @l int, @c varchar(020),
@D varchar(020)
SET @D = ''
declare loopcur cursor for select id from names
open loopcur
fetch next from loopcur into @b
while @@fetch_status = 0
begin
select @C = LTRIM(RTRIM(@B)) + ','
select @D = LTRIM(RTRIM(@D)) + LTRIM(RTRIM(@C))
fetch next from loopcur into @b
end
close loopcur
deallocate loopcur
select @d = left(@d, len(@d)-1 )
select @d as final
END

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the importance of concurrency control?

661


What are various aggregate functions that are available?

504


Can I run multiple instances of sql server 2000 at the same time on one computer?

594


Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?

78


A user is a member of the public role and the sales role. The public role has select permission on all the tables. The sales role does not have select permission on some of the tables will the user be able to select from all tables?

518






Explain query editor regions

612


What is a print index?

494


What is the Control Flow in SSIS

572


Can binary strings be converted into numeric or float data types?

548


What is partition, how will you implement it? : sql server analysis services, ssas

597


What are the new features of sql server 2012 reporting service?

84


what is the Ticketing tool used in Wipro technologies at Bangalore...???

7474


What are the different types of stored procedures?

546


Can sql servers link to other servers?

557


What is molap and its advantage? : sql server analysis services, ssas

543