Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2010
    Location
    Hyderabad
    Posts
    12

    Unanswered: Find all column names from Table

    Hi,

    I have 1 table it contains some no of columns but i need a query to know list of column names in that table.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Code:
    exec sp_help tablename

  3. #3
    Join Date
    Mar 2010
    Location
    Hyderabad
    Posts
    12

    Thumbs down

    Quote Originally Posted by MCrowley View Post
    Code:
    exec sp_help tablename
    Hi MCrowley,

    Thank yo very much your query helped me but i just want column names only.
    can u help me.

  4. #4
    Join Date
    Jun 2009
    Posts
    9
    Try this...

    select * from syscolumns where id = (select id from sysobjects where xtype='u' and name ='<table name>')

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    SELECT column_name
    FROM   information_schema.columns
    WHERE  table_name = 'table_name'
    
    SELECT name As column_name
    FROM   sys.columns
    WHERE  object_id = Object_ID('table_name')
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •