Getting the Create Table sql script

  • I'm looking for a way of getting the create table sql script.

    In mysql i use to do it with "SHOW CREATE TABLE table_name", but i cannot find any equivalent in mssql.

    Is there a SP that dose this?

    i'm new to mssql, so dont be very hursh with me

    thanks

  • In SQL Server it is easier right click on the table in the object browser in Query Analyzer then click on script object to new window then select create and you have your create table statement of your existing table.  Hope this helps.

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • i know this, but i need to do this form my app automatically and not from any visual tool.

  • I think you need sp_help.  Run a search for sp_help in the BOL (books online).  Hope this helps.

    sp_help [ [ @objname = ] name ]

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • Try a little sql dmo. there is no 1 command in t-sql to do it.

    http://www.sqlservercentral.com/columnists/awarren/lotsoftablesandalittledmo.asp

     

Viewing 5 posts - 1 through 5 (of 5 total)

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