none
How to Copy a Database from an existing database

    Question

  • I want to Create a database bass on another database just i want to copy a database
    Monday, May 20, 2013 8:58 AM

Answers

All replies

  • You need to backup and restore a database.

    Please refer the below articles:

    http://msdn.microsoft.com/en-us//library/ms187048.aspx

    http://msdn.microsoft.com/en-us/library/ms186865.aspx

    http://msdn.microsoft.com/en-us/library/ms186858.aspx

    


    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:

    http://msdn.microsoft.com/en-us/library/ms188664.aspx

    http://stackoverflow.com/questions/2043726/best-way-to-copy-a-database-sql-server-2008

    http://stackoverflow.com/questions/12485966/copy-a-sql-server-2008-database-and-rename-it


    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
    Moderator