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
 vertical format

Author  Topic 

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-11-05 : 01:17:28
I have this statement:

SELECT CI_LCprivacy
FROM dbo.ztestsmsaverage

the results:

Column1
CI_LCprivacy
0.978982300884955

I want it to be like this:

Column1 Column2
CI_LCprivacy 0.978982300884955

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-05 : 01:19:09
i think you can use
select * from information_schema.columns where table_name='youor table'

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-11-05 : 01:21:04
i didn't get it..sorry
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-05 : 01:56:04
run the query, and based on the results, you can join with some other viewa to get the desired result
select * from information_schema.columns where table_name='youtable_name'

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-11-05 : 02:00:39
can you give me the exact statement?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-05 : 02:01:34
or if column name is static just hardcode it n select
SELECT 'CI_LCprivacy' AS Col1,CI_LCprivacy AS Col2
FROM dbo.ztestsmsaverage
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-11-05 : 02:10:36
ok i got it..what if I want to change the first CI_LCprivacy to Question1?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-05 : 02:35:18
quote:
Originally posted by BankOfficerHere

ok i got it..what if I want to change the first CI_LCprivacy to Question1?



you mean alias or value?
if alias

SELECT 'CI_LCprivacy' AS Question1,CI_LCprivacy AS Col2
FROM dbo.ztestsmsaverage



if value

SELECT 'Question1' AS Col1,CI_LCprivacy AS Col2
FROM dbo.ztestsmsaverage


Go to Top of Page
   

- Advertisement -