Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    85

    Unanswered: Copy the table structure

    Hi,

    In SQL Server, Is there any DDL available to copy a table structure alone and not the data,

    I believe 'SELECT * into new_table from table1' will copy both structure and data as well.

    Please advice,

    Thanks,
    MiraJ

  2. #2
    Join Date
    Nov 2005
    Posts
    16
    You can use SELECT...INTO to create an identical table definition (different table name) with no data by having a FALSE condition in the WHERE clause.

    Code:
    SELECT * INTO new_table FROM table1 WHERE 1 = 0

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Understand though that Indexes and constraints do not get copied over...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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