Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2014
    Posts
    35

    Unanswered: How to retrieve table schema using SQL Server

    Hi Everyone,

    I am more familiar with writing SQL for Oracle than MS SQL Server. Within Oracle there is a simple command, 'Describe', which actually shows the data types, and whether or not an attribute accepts NULLS.

    MS SQL Server does appear to support such a command, however I am looking for a way to describe the attributes of tables nonetheless.

    If anybody can share some wisdom in this area it will be greatly appreciated.

    Kind Regards,

    David

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The preferred method is to use the information schema views. I would attach a URL link but I'm on a cell phone and can't get one in here.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Mar 2014
    Posts
    35
    Hi Pat,

    Thanks for taking the time to respond to my post. I have since gotten onto the following command -

    exec sp_help 'tablename'

    The above is answering 90% of what I needed to know.

    Kind Regards,

    Davo

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    A much closer match would be the INFORMATION_SCHEMA.COLUMNS view. All columns of all tables and views are available, and can be manipulated like any other result set. To find information about table fubar, you would use:
    Code:
    SELECT *
       FROM INFORMATION_SCHEMA.COLUMNS
       WHERE  'fubar' = TABLE_NAME
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Mar 2014
    Posts
    35

    Microsoft SQL Management Studio 2012 useful feature

    Hi Everyone,

    I have noticed that when using the * (wildcard) along with a table name it is possible to hover ones mouse over the * and see a list of important attributes (columns) displayed along with their key characteristics.

    http://oi58.tinypic.com/icpixw.jpg

    I hope that this pointer helps other users of Microsoft SQL Management Studio 2012.

    Kind Regards,

    Davo

Posting Permissions

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