Table Definition with Select Statemnt

  • How can I view a table definition (field names and datatypes) with a SELECT statement?

  • Use Information_schema views

    Ex:

    SELECT * FROM

    INFORMATION_SCHEMA.COLUMNS

    WHERE TABLE_NAME ='Your Table'


    * Noel

  • One caveat: if the user doesn't have access to the table/column, it won't show up in this query using the information schema views. If you're accessing as a user with db_datareader or db_owner, for instance, you'll be fine.

     

     

    K. Brian Kelley
    @kbriankelley

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply