How to Copy a Database from an existing database


All replies

  • You need to backup and restore a database.

    Please refer the below articles:


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Monday, May 20, 2013 9:01 AM
  • Follow these:

    Many Thanks & Best Regards, Hua Min

    Monday, May 20, 2013 9:02 AM
  • Hi  Das

    You can use Copy Wizard in SQL Server 2012 .

    Refer Article

    if you want to copy using script

    for Each table

    select * into Database.schema.targetTable from SourceDatabase.Schema.SourceTable

    Monday, May 20, 2013 9:05 AM
  • A database can contain more than tables alone (procs, UDDTs, functions, ...). Also, when referential integrity is in place (FKs and such) you can get ordering problems with a script. Therefore, I think that M--G's solution might not work.

    If the data should be included, use the backup / restore solution already suggested by other people in this thread. If you do not want the data, use a Visual Studio database project, import your database and then use VSDBCMD or SQLPackage (depending on the version of Visual Studio you use) to deploy the database project to a new, empty database.

    You can also backup and restore a database, disable all FKs, disable all triggers, delete all data from the database with a 'for each table, delete *', enable all FKs, enable all triggers, and finally, validate all FKs (do not forget this step).

    Monday, May 20, 2013 9:23 AM
  • You can use SSMS Generate Scripts wizard to generate all your database objects in script file(s) without data (or with data if you choose the setting). An easy way is a simple backup and restore approach as other posters suggested.
    Monday, May 20, 2013 2:52 PM