Print Column names vertically from table

  • I want to print column names from table vertically without using pivot/unpivot .

  • Would you mind providing an example of what you're looking for?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • My table contains

    eid fname lname gender age title

    I want to print like this

    eid

    fname

    lname

    gender

    age

    title .

  • 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

  • Thank You Gah . It worked out

  • Or you could use Information_Schema views

    Like :

    SELECT * FROM INFORMATION_SCHEMA.COLUMNS

    WHERE TABLE_NAME = 'TABLE'

  • 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

  • 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.

  • 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