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

Can a trigger call a stored procedure?

1077


How to select unique records from a table?

1066


Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?

1041


What is a sql statement?

975


Is sql microsoft?

1062


What is use of term?

1070


What is the difference between a database and a relational database?

1111


how to fetch alternate records from a table? : Sql dba

1122


Why cross join is used?

1084


What are the most important characteristics of pl/sql?

1168


What is the difference between union and union all command?

1096


What is difference between joins and union?

1136


Are subqueries faster than joins?

1027


Can there be more than one function with a similar name in a pl/sql block?

996


how can we transpose a table using sql (changing rows to column or vice-versa) ? : Sql dba

964