Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Posts
    83

    Question Unanswered: is it possible Copy the table structures of all the tables without copying the data.

    CREATE TABLE table_name AS SELECT STATEMENT WHERE rownum = 0;
    this query will copy the table structure of one table without copying the data. I need to copy the table structures of all the tables in a particular database without copying the data.
    suggest me on this.
    Last edited by krReddy; 11-16-06 at 07:29. Reason: modification

  2. #2
    Join Date
    Oct 2006
    Posts
    83

    any body from microsoft

    any body from microsoft

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    gee I almost worked for microsoft. is that good enough?

    in SQL2k, right click on your database in the Enterprise Mangler and choose Generate SQL script.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    rownum = 0?

    What version are you talking about
    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.

  5. #5
    Join Date
    Oct 2006
    Posts
    83
    SQL Server 2000

  6. #6
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by krReddy
    SQL Server 2000
    Are you running this statement in sql server 2000? I don't think so...
    Code:
    CREATE TABLE table_name AS SELECT STATEMENT WHERE rownum = 0;
    Please check your requirement,
    That will not work at all,but this will
    Code:
    SELECT TOP 0 * INTO NewTable FROM OldTable
    well Thrasymachus has already given you the solution.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  7. #7
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    You can try an app I wrote for this called scriptdb. It will create scripts for ALL objects, not just tables, a separate file for each.

    the source is freely available so you can modify it to suit your needs if you know C#.

    get it here: http://www.elsasoft.org/tools.htm

    EDIT: and I used to be a dev on the ms sql team, but no longer. does that count?

Posting Permissions

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