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

Explain mixed authentication mode of sql server?

1052


What is the use of “join” in sql server?

1084


What is the recovery model? List the types of recovery model available in sql server?

900


Ms sql server index?

1060


What are the types of stored procedures in an sql server?

981


Name 3 ways to get an accurate count of the number of records in a table?

1031


What are different types of data sources?

1008


Write a query to include a constraint, to check whether the employee salary is greater than 5000?

1600


When would you use an insert into .. Select option versus an insert into .. Values option? Give an example of each?

1095


What is the difference between push and pull subscription? : sql server replication

1209


What is the use of keyword with encryption. Create a store procedure with encryption?

956


What is xdr?

985


What is sql profiler. What are the default templates with it? : sql server database administration

1028


What happens when the SQL Azure database reaches Max Size?

111


Show Practically Sql Server Views are updatable?

1113