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
What is the importance of concurrency control?
What are various aggregate functions that are available?
Can I run multiple instances of sql server 2000 at the same time on one computer?
Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?
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?
Explain query editor regions
What is a print index?
What is the Control Flow in SSIS
Can binary strings be converted into numeric or float data types?
What is partition, how will you implement it? : sql server analysis services, ssas
What are the new features of sql server 2012 reporting service?
what is the Ticketing tool used in Wipro technologies at Bangalore...???
What are the different types of stored procedures?
Can sql servers link to other servers?
What is molap and its advantage? : sql server analysis services, ssas