September 4, 2010 at 10:25 am
I want to print column names from table vertically without using pivot/unpivot .
September 4, 2010 at 10:50 am
Would you mind providing an example of what you're looking for?
September 4, 2010 at 11:04 am
My table contains
eid fname lname gender age title
I want to print like this
eid
fname
lname
gender
age
title .
September 4, 2010 at 11:06 am
any good?
SELECT st.name,
sc.name
FROM sys.all_columns sc
JOIN sys.tables st
ON st.object_id = sc.object_id
WHERE st.name = '<your table name>'
ORDER BY st.name
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
September 4, 2010 at 11:32 am
Thank You Gah . It worked out
September 4, 2010 at 12:22 pm
Or you could use Information_Schema views
Like :
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TABLE'
September 4, 2010 at 4:37 pm
One problem with using Information_Schema and catalog views is that the user executing the query must have access to the object(s) being referenced.
MCITP SQL Server 2005/2008 DBA/DBD
September 4, 2010 at 5:05 pm
select column_name from information_schema.columns
where table_name= 'tablename'
if I type * instead of column_name it is giving database name not columns name.
September 4, 2010 at 9:31 pm
I am able to see lot of things about a column name when i query Information_Schema.Columns
PFA the screenshot of my query
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply