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 does man by sql wildcard characters in sql server?
Does full backup break log chain?
What is buffer cash in sql server?
What are subquery and its properties?
How many types of objects are there?
What is postgresql server?
How will you add a dimension to cube? : sql server analysis services, ssas
What should be the fill factor for indexes created on tables? : sql server database administration
how would you store your query in an SSRS report or a Database server?
What is a domain constraint give an example?
Which joins are sql server default?
What is data source in connection string?
Why do we use trigger?
tell me what are the steps you will take to improve performance of a poor performing query? : Sql server database administration
Which is faster statement or preparedstatement?