Copy Table Structure

  • I am coming to SQL Server from Access, where just about everything you need is in the GUI, so natch I am having some problems 🙂

    what about copying a table structure to a new table in the same database?

    any help will be appreciated

  • If you just want to duplicate the table structure and not the data:

    select * into <newtable> from <sourcetable> where 1 = 0


    Regards,

    Carlos

  • Carlos' method is probably the quickest but you could create a CREAT TABLE script

    In SSMS right click on the table > Script Table as.. > Create To..

    You can then change the name of the table in the create script and then run it in query window.

    This way it helps you to understand how a table is created etc


    Everything you can imagine is real.

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

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