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 are the common performance issues in sql server?
What is the difference between TRUNCATE and DROP?
What is the data tier application?
What is a recursive stored procedure in sql server?
What is the status of services on passive node for failover cluster in sql server? : sql server database administration
What is PROJECTION Operation?
What is an entity-relationship diagram (erd)?
What are the steps you must follow to hide sql server instances?
What are functions in the sql server?
How to encrypt data between dialogs?
What is a full text index?
How to execute the cursor queries with "open" statements?
Explain microsoft sql server functions?
you have couple of stored procedures that depend on a table you dropped the table and recreated it what do you have to do to reestablish those stored procedure dependencies?
Does view occupy space?