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 mixed authentication mode of sql server?
What is the use of “join” in sql server?
What is the recovery model? List the types of recovery model available in sql server?
Ms sql server index?
What are the types of stored procedures in an sql server?
Name 3 ways to get an accurate count of the number of records in a table?
What are different types of data sources?
Write a query to include a constraint, to check whether the employee salary is greater than 5000?
When would you use an insert into .. Select option versus an insert into .. Values option? Give an example of each?
What is the difference between push and pull subscription? : sql server replication
What is the use of keyword with encryption. Create a store procedure with encryption?
What is xdr?
What is sql profiler. What are the default templates with it? : sql server database administration
What happens when the SQL Azure database reaches Max Size?
Show Practically Sql Server Views are updatable?