Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the operating modes in which database mirroring runs?

1025


Tell me what is difference between clustered and non clustered index?

896


What is the difference between a view and a stored procedure?

979


What is right outer join in sql server joins?

1120


What is an execution plan?

1056


Relational calculus is what type of language?

976


Mention the differences between substr and charindex in sql server.

983


What is the main difference between ‘between’ and ‘in’ condition operators?

1103


Explain activity monitors

1004


How do I trace a query in sql server?

900


Explain active/passive and active/active cluster configurations?

1014


Can you please differentiate between a primary key and a unique key?

950


What do you understand by replication in sql server? Mention the different types of replication in sql server.

893


What is instead of trigger sql server?

930


Explain what is lock escalation and what is its purpose?

874