0 Replies - 1779 Views - Last Post: 01 July 2008 - 08:34 PM

#1 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,155
  • Joined: 10-May 07

MSSQL equivalent to describe

Posted 01 July 2008 - 08:34 PM

Description: change tablename to the appropriate name of the table you are getting details on.Since MSSQL does not offer the describe command, it can be frustrating digging through the columns. Maybe this can help!
SELECT
    column_name
,   data_type +
    COALESCE(
       '(' + CAST(character_maximum_length AS VARCHAR) + ')'
    ,  '(' + CAST(numeric_precision AS VARCHAR) + ')'
    ,  ''
    )
,   column_default
,   constraint_type
,   is_nullable
FROM
    information_schema.columns
WHERE
    table_name = 'tablename';


Is This A Good Question/Topic? 0
  • +

Replies To: MSSQL equivalent to describe

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,155
  • Joined: 10-May 07

Re: MSSQL equivalent to describe

Posted 01 July 2008 - 08:34 PM

Description: change tablename to the appropriate name of the table you are getting details on.Since MSSQL does not offer the describe command, it can be frustrating digging through the columns. Maybe this can help! Found at http://www.crydust.b...cribe-statement : and added constraint_type
SELECT
    column_name
,   data_type +
    COALESCE(
       '(' + CAST(character_maximum_length AS VARCHAR) + ')'
    ,  '(' + CAST(numeric_precision AS VARCHAR) + ')'
    ,  ''
    )
,   column_default
,   constraint_type
,   is_nullable
FROM
    information_schema.columns
WHERE
    table_name = 'tablename';

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1