Re: Database copy
- From: "Marcos" <marcos_rodas@xxxxxxxxxxx>
- Date: Fri, 9 Nov 2007 14:58:35 -0700
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
"Erland Sommarskog" <esquel@xxxxxxxxxxxxx> wrote in message
news:Xns99E3D4EF9DF4Yazorman@xxxxxxxxxxxx
msnews (marcos_rodas@xxxxxxxxxxx) 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, esquel@xxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: Database copy
- From: Erland Sommarskog
- Re: Database copy
- References:
- Database copy
- From: msnews
- Re: Database copy
- From: Erland Sommarskog
- Re: Database copy
- From: msnews
- Re: Database copy
- From: Erland Sommarskog
- Database copy
- Prev by Date: Re: Database copy
- Next by Date: Re: Database copy
- Previous by thread: Re: Database copy
- Next by thread: Re: Database copy
- Index(es):
Relevant Pages
|