Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi
SQL
CREATE TABLE Product_temp(Cust VARCHAR(25), Product VARCHAR(20), QTY INT)

INSERT INTO Product_temp(Cust, Product, QTY) VALUES(KATE,VEG,2)

SELECT * FROM Product_temp

Now the answer needed as

TYPE VALUES
CUST KATE
PRODUCT VEG
QTY 2
Posted

1 solution

Hi,

Try Below sql

SQL
select Type,value  FROM
(select cust = convert (varchar,cust),Product = convert (varchar,Product),QTY = convert (varchar,QTY) from Product_temp ) c
UNPIVOT
(Value FOR Type IN ([cust],[Product], [QTY] ) ) AS p
 
Share this answer
 
Comments
Shanalal Kasim 11-Apr-13 7:52am    
Please vote

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900