Professional Web Applications Themes

How do I copy a database on the same server with a different name? - Microsoft SQL / MS SQL Server

You can backup a database and restore it with a different name. You can do this in EM, but I guess the same would be possible through T-SQL also. -- HTH, SriSamp Please reply to the whole group only! http://www32.brinkster.com/srisamp "Raanan Avidor" <com> wrote in message news:phx.gbl... ...

  1. #1

    Default Re: How do I copy a database on the same server with a different name?

    You can backup a database and restore it with a different name.
    You can do this in EM, but I guess the same would be possible through T-SQL
    also.
    --
    HTH,
    SriSamp
    Please reply to the whole group only!
    http://www32.brinkster.com/srisamp

    "Raanan Avidor" <com> wrote in message
    news:phx.gbl... 


    SriSamp Guest

  2. #2

    Default How do I copy a database on the same server with a different name?

    How do I copy a database on the same server with a different name?

    Raanan


    Raanan Guest

  3. #3

    Default Re: How do I copy a database on the same server with a different name?

    See following example of Backup/Restore database(using T-SQL) with the new
    name (Northwind database).

    --Backup the original database
    BACKUP DATABASE [Northwind] TO DISK = N'C:\north.bak' with init
    go
    --Following is the command that will create a new database with the existing
    backup file of northwind database
    RESTORE DATABASE [Northwind_NEW] FROM DISK = N'C:\north.bak'
    WITH RECOVERY ,
    MOVE N'Northwind_log' TO N'C:\Northwind_NEW_log.ldf', --new location/name
    MOVE N'Northwind' TO N'C:\Northwind_NEW.mdf' --new location/name
    go

    You can also use sp_detach_db/sp_attach_db to create a new database with new
    name

    --
    -Vishal

    "Raanan Avidor" <com> wrote in message
    news:phx.gbl... 


    Vishal Guest

  4. #4

    Default Re: How do I copy a database on the same server with a different name?

    Correct. This can be done via the Transact-SQL commands BACKUP and RESTORE.
    When you perform the restore make sure that you give the database a new name. You will want to make sure that you use WITH MOVE (part of the restore script) to move the physical files to a different location (by default restore will try to place the files where they were when the backup was taken).

    --
    Keith, SQL Server MVP

    "SriSamp" <co.in> wrote in message news:phx.gbl... 
    >
    >[/ref]
    Keith Guest

Similar Threads

  1. how to copy indexes to a new database
    By psawant@gmail.com in forum MySQL
    Replies: 2
    Last Post: November 24th, 12:52 AM
  2. Copy database from MySQL to MSAccess
    By Kjell Hansen in forum PHP Development
    Replies: 3
    Last Post: September 2nd, 10:01 AM
  3. Copy file to database
    By Martin de vroom in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: June 30th, 04:30 PM
  4. How to copy records from one database to another one ?
    By Jesus Gonzalez in forum FileMaker
    Replies: 3
    Last Post: June 28th, 03:03 PM
  5. Copy Database from NT to W2K
    By Giuseppe in forum Oracle Server
    Replies: 3
    Last Post: December 26th, 11:39 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139