Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Column info in SQL Server 2005

Column info in SQL Server 2005

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    I explore code
    wrote on last edited by
    #1

    Hi, I need to retrieve the column info only from a table that i created in the DB. Though I know it can be done using sys.objects/sys.columns, i do not know how to form the query. please help.

    T 1 Reply Last reply
    0
    • I I explore code

      Hi, I need to retrieve the column info only from a table that i created in the DB. Though I know it can be done using sys.objects/sys.columns, i do not know how to form the query. please help.

      T Offline
      T Offline
      Tirthadip
      wrote on last edited by
      #2

      Retrieving column names of a table There are basically 3 approaches to this problem: 1.Use the sp_help procedure to get extended information about a database object. By database object, we mean a table, view etc. 2.You can use the following select statement to retrieve a table’s columns: SELECT TOP 0 * FROM table_name 3.The third approach, which I personally prefer, is using the schema object of SQL Server. For example, to retrieve the column names of Authors table, you can use the following SELECT statement: SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME 'authors' Which results in the following result set: column_name ---------------------------- au_id au_lname au_fname phone address city state zip contract (9 row(s) affected)

      Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups