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. Name and Data Type of all columns

Name and Data Type of all columns

Scheduled Pinned Locked Moved Database
databasesharepointtoolsquestion
4 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.
  • D Offline
    D Offline
    DotNet_Newbie
    wrote on last edited by
    #1

    Hello All, I have a SQL 200 DB in place, but now I want to run a script or SP that will give me as an output the name and data type of all the columns in one of the tables. Any Ideas? Thanks in Advance.

    J 1 Reply Last reply
    0
    • D DotNet_Newbie

      Hello All, I have a SQL 200 DB in place, but now I want to run a script or SP that will give me as an output the name and data type of all the columns in one of the tables. Any Ideas? Thanks in Advance.

      J Offline
      J Offline
      Jeff Varszegi
      wrote on last edited by
      #2

      SELECT
         COLUMN_NAME,
         DATA_TYPE
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE TABLE_NAME = 'whimsy'
      ORDER BY ORDINAL_POSITION

      Regards, Jeff Varszegi EEEP!  An Extensible Expression Evaluation Package

      D 1 Reply Last reply
      0
      • J Jeff Varszegi

        SELECT
           COLUMN_NAME,
           DATA_TYPE
        FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_NAME = 'whimsy'
        ORDER BY ORDINAL_POSITION

        Regards, Jeff Varszegi EEEP!  An Extensible Expression Evaluation Package

        D Offline
        D Offline
        DotNet_Newbie
        wrote on last edited by
        #3

        Thank you..

        J 1 Reply Last reply
        0
        • D DotNet_Newbie

          Thank you..

          J Offline
          J Offline
          Jeff Varszegi
          wrote on last edited by
          #4

          You're welcome! I assume you have access to Query Analyzer, yes? You could spend a fun couple of hours just poking around in 1) the master.dbo tables, where lots of useful information is stored; 2) INFORMATION_SCHEMA views, which Microsoft recommends whenever possible; 3) the other databases like msdb, where job and replication info is stored etc. etc. Also look up system functions and sp_ stored procedures in books online. After all that, you'll have the beginnings of the beginnings of a good working knowledge of SQL Server. And get your boss to spring for the Microsoft Press books on SQL Server; they're really good. Regards, Jeff Varszegi EEEP!  An Extensible Expression Evaluation Package

          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