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...

have table with two columns with datatypes as number and
varchar and the values in
A column like 1,2,3 AND B column values like a,b,c.
now need to display data in a single column as 1,a,2,b,3,c.

Answer Posted / saravanan

Try this way!

create table stest(num int,name varchar(10),value numeric
(10,2));

insert into stest values(101,'SARAN',1000.58);
insert into stest values(102,'KALA',1200.18);
insert into stest values(103,'AYYA',3000.40);
insert into stest values(104,'RATNA',4000.57);

SELECT * FROM STEST;

declare @str varchar(2000);
set @str = null;
select @str=ISNULL(@str+',','')+ltrim(STR(num))+','+name
from stest
select @str;

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to start the command-line sql*plus?

1046


What are the advantages of sql? Explain

1092


How to rename a table?

1010


Which sql statement is used to return only different values?

995


Which is better varchar or nvarchar?

990


Explain raise_application_error.

1084


What is a data definition language?

1094


Can primary key be changed?

902


What are local and global Indexes and where they are useful.

1435


What is the purpose of the primary key?

1055


Write a program that shows the usage of while loop to calculate the average of user entered numbers and entry of more numbers are stopped by entering number 0?

2274


Compare sql & pl/sql

1121


What are different categories of sql commands?

1125


How consistent is the view of the data between and within multiple sessions, transactions or statements ?

2213


What is a recursive join sql?

1061