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
Explain the categories of stored procedure?
what are acid properties? : Sql server database administration
Which data type columns are the best candidates for full-text indexing?
Define clusters?
How do you run a trace?
What are the types of subscriptions in SQL Server replication?
Write a code to select distinct records without using the DISTINCT keyword.
What is an active database?
your distribution database is full what will u do
Difference between report and query parameter. Why do we need different type of parameter?
What is nolock hint in sql server 2008
What are two difference between sql azure and azure tables?
Why use “pivot” in sql server?
Explain “row_number()” in sql server with an example?
What is cursors?