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 operating modes in which database mirroring runs?
Tell me what is difference between clustered and non clustered index?
What is the difference between a view and a stored procedure?
What is right outer join in sql server joins?
What is an execution plan?
Relational calculus is what type of language?
Mention the differences between substr and charindex in sql server.
What is the main difference between ‘between’ and ‘in’ condition operators?
Explain activity monitors
How do I trace a query in sql server?
Explain active/passive and active/active cluster configurations?
Can you please differentiate between a primary key and a unique key?
What do you understand by replication in sql server? Mention the different types of replication in sql server.
What is instead of trigger sql server?
Explain what is lock escalation and what is its purpose?