locked
Making create script from an existing database RRS feed

  • Question

  • Hi Guys, how do I generate a script that would say recreate the existing database on another db server without the data. So just the existing table schema?

    I need to take a copy of the schema from production db and create it in a development db. sql 2008.

     

    cheers.

    Wednesday, January 11, 2012 11:45 AM

Answers

  • HI,

    Have you looked below option:

    In SSMS, Right click your database -> Tasks -> Generate Scripts

    It's a wizard and on 2-3 window you will have option to script data (yes / no)


    Regards,

    Asim Bagwan

    Kindly mark the replies as Answers if they help!

    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Wednesday, January 11, 2012 11:50 AM
  • I wrote a blog post on how you can script out dtabase tables and also their statistics, this means that you can run estimated queries against the schema, cool stuff. you can read about it here - http://sql.richarddouglas.co.uk/archive/2011/11/writing-queries-without-data.html
    If you find this helpful, please mark the post as helpful,
    If you think this solves the problem, please propose or mark it an an answer.

    Please provide details on your SQL Server environment such as version and edition, also DDL statements for tables when posting T-SQL issues

    Richard Douglas
    My Blog: Http://SQL.RichardDouglas.co.uk
    Twitter: @SQLRich
    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Wednesday, January 11, 2012 1:26 PM
  • Thanks,

    You need to do:

    1. Table->Create to->Clipboard
    2. Remove the data file and log commands
    3. Once table is created, right click on original db and generate scripts
    4. Select generate tables
    5. Run that on the new db
    6. Create users

    Seems to work, bit of effort.

    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Thursday, January 12, 2012 10:27 AM

All replies

  • HI,

    Have you looked below option:

    In SSMS, Right click your database -> Tasks -> Generate Scripts

    It's a wizard and on 2-3 window you will have option to script data (yes / no)


    Regards,

    Asim Bagwan

    Kindly mark the replies as Answers if they help!

    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Wednesday, January 11, 2012 11:50 AM
  • I wrote a blog post on how you can script out dtabase tables and also their statistics, this means that you can run estimated queries against the schema, cool stuff. you can read about it here - http://sql.richarddouglas.co.uk/archive/2011/11/writing-queries-without-data.html
    If you find this helpful, please mark the post as helpful,
    If you think this solves the problem, please propose or mark it an an answer.

    Please provide details on your SQL Server environment such as version and edition, also DDL statements for tables when posting T-SQL issues

    Richard Douglas
    My Blog: Http://SQL.RichardDouglas.co.uk
    Twitter: @SQLRich
    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Wednesday, January 11, 2012 1:26 PM
  • Thanks,

    You need to do:

    1. Table->Create to->Clipboard
    2. Remove the data file and log commands
    3. Once table is created, right click on original db and generate scripts
    4. Select generate tables
    5. Run that on the new db
    6. Create users

    Seems to work, bit of effort.

    • Marked as answer by infused Thursday, January 12, 2012 10:27 AM
    Thursday, January 12, 2012 10:27 AM