Results 1 to 4 of 4

Thread: Determining table's column name in sql server

  1. #1
    Join Date
    Jan 2009
    Posts
    51

    Determining table's column name in sql server

    I have a sql server running. Is there anyway to find out the column name with a query. I don't need any data for the same but just the column name. Help guys!

  2. #2
    Join Date
    Apr 2008
    Posts
    4,642

    Re: Determining table's column name in sql server

    Try this query, may be thsi is what you want :
    Code:
    SELECT column_name
    FROM information_schema.columns
    WHERE table_schema = 'schema_name'
    AND table_name = 'table_name' ;

  3. #3
    Join Date
    May 2008
    Posts
    3,316

    Re: Determining table's column name in sql server

    One other way, that may work :
    Code:
    SELECT table_name, column_name
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE table_name = 'my_table_name'

  4. #4
    Join Date
    May 2008
    Posts
    4,570

    Re: Determining table's column name in sql server

    This may work for SQL 2005 and above versions :
    Code:
    SELECT name
    FROM sys.columns
    WHERE [object_id] = OBJECT_ID('dbo.tablename');

Similar Threads

  1. What is the way to sum up number of column in Pivot Table
    By Dvimida in forum MS Office Support
    Replies: 2
    Last Post: 09-02-2012, 07:31 PM
  2. How to use table column as data validation list
    By connoisseur in forum MS Office Support
    Replies: 2
    Last Post: 13-01-2012, 06:10 PM
  3. How to add new column in table in sql server
    By MKAIF in forum Software Development
    Replies: 4
    Last Post: 02-02-2010, 08:34 PM
  4. Excel Macro querying a table by column name
    By Halyn in forum Software Development
    Replies: 3
    Last Post: 14-10-2009, 08:59 PM
  5. Word 2008 problem with column in table
    By Hakon in forum Software Development
    Replies: 2
    Last Post: 28-04-2009, 12:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,393,416.47059 seconds with 16 queries