Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to devide????????

Author  Topic 

sweet_777
Starting Member

16 Posts

Posted - 2010-10-21 : 08:25:44
hI ALL,

MY SQL QUERY IS LIKE THIS:

SELECT EMPID,EMPNAME,SAL FROM EMP

0/P:EMPID,EMPNAME,SAL
1 A 1000,
2 B 2000,
3 C 3000

BUT MY REQUIREMENT IS :
COLUMN(SOME ALIAS NAME )
1
A
1000
2
B
2000
3
C
3000

HOW TO DO

HOW TO DEVIDE SINGLE 3 COLUMNS INTO ROWS.



Thanks & Regards
Sweet_77

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2010-10-21 : 09:05:38
I'd do this in the UI. columns don't have the same datatype so you'd have to cast them all to strings to do it.


elsasoft.org
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-23 : 02:12:38
also do you have any other column to determine the order of retrieval?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-10-23 : 02:52:17
[code]
declare @tbl table(nm varchar(10),id int)
insert into @tbl
select 'a',1 union
select 'b',2

select col from
(
select nm,CONVERT(varchar(10),id)id from @tbl)u
unpivot (col for columns in(nm,id))v
[/code]

PBUH

Go to Top of Page
   

- Advertisement -