Home All Groups Group Topic Archive Search About
Author
8 Nov 2007 9:07 PM
msnews
I like to use the copy database tool to copy 15 databases from a production
SQL 2005 64 Bit to a test SQL 2005 64 Bit system. Is there a documentation
specific about how to do it?

Author
8 Nov 2007 10:08 PM
Erland Sommarskog
msnews (marcos_ro***@hotmail.com) writes:
> I like to use the copy database tool to copy 15 databases from a
> production SQL 2005 64 Bit to a test SQL 2005 64 Bit system. Is there a
> documentation specific about how to do it?

I've never tried it, but it as appear that the Copy Database Wizard
permits you to copy many databases at a time, alhtough you always start
it from the context of a specific database.

Be sure to use the attach/detach method. The SMO method is very unreliable.

Many people would use BACKUP/RESTORE directly rather than dealing
with the wizard.


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
9 Nov 2007 3:23 PM
msnews
I like to use BACKUP/RESTORE but without bringing any users (from source
backup database).

Show quote
"Erland Sommarskog" <esq***@sommarskog.se> wrote in message
news:Xns99E2EC87C6BB7Yazorman@127.0.0.1...
> msnews (marcos_ro***@hotmail.com) writes:
>> I like to use the copy database tool to copy 15 databases from a
>> production SQL 2005 64 Bit to a test SQL 2005 64 Bit system. Is there a
>> documentation specific about how to do it?
>
> I've never tried it, but it as appear that the Copy Database Wizard
> permits you to copy many databases at a time, alhtough you always start
> it from the context of a specific database.
>
> Be sure to use the attach/detach method. The SMO method is very
> unreliable.
>
> Many people would use BACKUP/RESTORE directly rather than dealing
> with the wizard.
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
9 Nov 2007 7:49 PM
Erland Sommarskog
msnews (marcos_ro***@hotmail.com) writes:
> I like to use BACKUP/RESTORE but without bringing any users (from source
> backup database).

The easiest would be to drop the users when you have restored the datbase.

SELECT 'DROP USER ' + name FROM sys.database_principals
WHERE name NOT IN ('dbo', 'guest', 'sys', 'INFORMATION_SCHEMA')
  AND type_desc = 'SQL_USER'

If any user but dbo owns objects, for instance schemas, you will hit some
snags, and you will need to decide what to do in that case.

--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
9 Nov 2007 9:58 PM
Marcos
I guess I'll need a script to restore the database then drop the users.
Are this the commands I need to restore the database?

RESTORE DATABASE database_name
FROM DISK = 'C:\Backups\database_name.BAK'
WITH NORECOVERY

Show quote
"Erland Sommarskog" <esq***@sommarskog.se> wrote in message
news:Xns99E3D4EF9DF4Yazorman@127.0.0.1...
> msnews (marcos_ro***@hotmail.com) writes:
>> I like to use BACKUP/RESTORE but without bringing any users (from source
>> backup database).
>
> The easiest would be to drop the users when you have restored the datbase.
>
> SELECT 'DROP USER ' + name FROM sys.database_principals
> WHERE name NOT IN ('dbo', 'guest', 'sys', 'INFORMATION_SCHEMA')
>  AND type_desc = 'SQL_USER'
>
> If any user but dbo owns objects, for instance schemas, you will hit some
> snags, and you will need to decide what to do in that case.
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
9 Nov 2007 10:24 PM
Erland Sommarskog
Marcos (marcos_ro***@hotmail.com) writes:
> I guess I'll need a script to restore the database then drop the users.
> Are this the commands I need to restore the database?
>
> RESTORE DATABASE database_name
> FROM DISK = 'C:\Backups\database_name.BAK'
> WITH NORECOVERY

Depends. Only use WITH NORECOVERY if you intend to also restore
transaction logs. Which you usually don't want when you copy a database.

Also, when you copy a database to different locations or different
names, SQL Server can be picky about details, leading to this
command:


   RESTORE DATABASE db
   FROM DISK = 'backuppath'
   WITH MOVE 'logicalname1' TO 'phyiscalpath1',
        MOVE 'logicalname2' TO 'physicalpath2',
        REPLACE

The logical names are the internal names of the database files, and
you can find then with sp_helpdb to RESTORE FILELISTONLY.

physicalpath1 is the place for the files of the restored database.



--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
12 Nov 2007 4:20 PM
Marcos
I tried restoring from a copy of a backup but it wouldn't recognize it as
being a backup file. I guess I'll need to do the WITH MOVE command.

Show quote
"Erland Sommarskog" <esq***@sommarskog.se> wrote in message
news:Xns99E3EF2927139Yazorman@127.0.0.1...
> Marcos (marcos_ro***@hotmail.com) writes:
>> I guess I'll need a script to restore the database then drop the users.
>> Are this the commands I need to restore the database?
>>
>> RESTORE DATABASE database_name
>> FROM DISK = 'C:\Backups\database_name.BAK'
>> WITH NORECOVERY
>
> Depends. Only use WITH NORECOVERY if you intend to also restore
> transaction logs. Which you usually don't want when you copy a database.
>
> Also, when you copy a database to different locations or different
> names, SQL Server can be picky about details, leading to this
> command:
>
>
>   RESTORE DATABASE db
>   FROM DISK = 'backuppath'
>   WITH MOVE 'logicalname1' TO 'phyiscalpath1',
>        MOVE 'logicalname2' TO 'physicalpath2',
>        REPLACE
>
> The logical names are the internal names of the database files, and
> you can find then with sp_helpdb to RESTORE FILELISTONLY.
>
> physicalpath1 is the place for the files of the restored database.
>
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
12 Nov 2007 5:07 PM
Marcos
I guess is the BACKUP the one bringing the users with the database. Is there
a way to run a BACKUP without the users? I know I should be able to remove
the users once I restore the database, but I just like to see if I can take
care of the users before the RESTORE.

Thanks for all your help.

Show quote
"Marcos" <marcos_ro***@hotmail.com> wrote in message
news:esAmjfUJIHA.1204@TK2MSFTNGP03.phx.gbl...
>I tried restoring from a copy of a backup but it wouldn't recognize it as
>being a backup file. I guess I'll need to do the WITH MOVE command.
>
> "Erland Sommarskog" <esq***@sommarskog.se> wrote in message
> news:Xns99E3EF2927139Yazorman@127.0.0.1...
>> Marcos (marcos_ro***@hotmail.com) writes:
>>> I guess I'll need a script to restore the database then drop the users.
>>> Are this the commands I need to restore the database?
>>>
>>> RESTORE DATABASE database_name
>>> FROM DISK = 'C:\Backups\database_name.BAK'
>>> WITH NORECOVERY
>>
>> Depends. Only use WITH NORECOVERY if you intend to also restore
>> transaction logs. Which you usually don't want when you copy a database.
>>
>> Also, when you copy a database to different locations or different
>> names, SQL Server can be picky about details, leading to this
>> command:
>>
>>
>>   RESTORE DATABASE db
>>   FROM DISK = 'backuppath'
>>   WITH MOVE 'logicalname1' TO 'phyiscalpath1',
>>        MOVE 'logicalname2' TO 'physicalpath2',
>>        REPLACE
>>
>> The logical names are the internal names of the database files, and
>> you can find then with sp_helpdb to RESTORE FILELISTONLY.
>>
>> physicalpath1 is the place for the files of the restored database.
>>
>>
>>
>> --
>> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>>
>> Books Online for SQL Server 2005 at
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
>> Books Online for SQL Server 2000 at
>> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
>
Author
12 Nov 2007 10:07 PM
Erland Sommarskog
Marcos (marcos_ro***@hotmail.com) writes:
> I guess is the BACKUP the one bringing the users with the database. Is
> there a way to run a BACKUP without the users? I know I should be able
> to remove the users once I restore the database, but I just like to see
> if I can take care of the users before the RESTORE.

No, neither BACKUP nor RESTOARE are selective on that level. (You can
backup/restore a filegroup only, but that is not going to help you
here.)



--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

AddThis Social Bookmark Button