[dba-SQLServer] Copy a database using a store procedure orfunction

jwcolby jwcolby at colbyconsulting.com
Tue Mar 25 16:36:17 CDT 2008


Elizabeth,

Thanks for the code.  I am trying it now.  I would like to make one comment
though.

>This is from BOL for SQL Server 2005, which is often amazingly helpful.

First of all, what is you job?  What do you do?

My comment is that, the instruction manual for flying a DC10 is almost
assuredly "amazingly useful" to the right people.  If I just want to get to
London by tomorrow night, it is probably about as useful as the proverbial
"tits on a boar".  That manual and a two thousand dollars will get you a
ticket to London.

I have spent hours in BOL (really!).  It has rarely been "amazingly useful",
in fact I can't say that I have EVER found it such.  But then my job is not
writing SQL Server TSQL code day in and day out.  If that were my job then I
am absolutely sure it would be "amazingly useful" to me.

I used the "flight manual" example because when I was a teenager, I had a
job cleaning apartments after people moved out.  I was cleaning an apartment
and found the maintenance manual for an army helicopter.  While it was
fascinating, it was also "totally useless" to me.  OTOH it was no doubt
"amazingly useful" to the guy who left it behind.

My job is not to write TSQL.  Very occasionally I am forced to do so because
there are no easier to use tools but that doesn't mean that I will EVER know
enough to find BOL "amazingly useful".

John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of
Elizabeth.J.Doering at wellsfargo.com
Sent: Tuesday, March 25, 2008 4:10 PM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] Copy a database using a store procedure
orfunction

I haven't used this (being pretty new to this myself), but I'm sure some one
else here can speak to it:

E. Make a copy of a database using BACKUP and RESTORE This example uses both
the BACKUP and RESTORE statements to make a copy of the AdventureWorks
database. The MOVE statement causes the data and log file to be restored to
the specified locations. The RESTORE FILELISTONLY statement is used to
determine the number and names of the files in the database being restored.
The new copy of the database is named TestDB. For more information, see
RESTORE FILELISTONLY (Transact-SQL). 

 Copy Code
BACKUP DATABASE AdventureWorks 
   TO DISK = 'C:\AdventureWorks.bak'

RESTORE FILELISTONLY 
   FROM DISK = 'C:\AdventureWorks.bak'

RESTORE DATABASE TestDB 
   FROM DISK = 'C:\AdventureWorks.bak'
   WITH MOVE 'AdventureWorks_Data' TO 'C:\testdb.mdf',
   MOVE 'AdventureWorks_Log' TO 'C:\testdb.ldf'
GO
 
This is from BOL for SQL Server 2005, which is often amazingly helpful.

HTH,


Liz 


Liz Doering
elizabeth.j.doering at wellsfargo.com
612.667.2447 




More information about the dba-SQLServer mailing list