Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup & Replicat Databases

Status
Not open for further replies.

RPG42

Programmer
Jan 7, 2005
12
0
0
US
Hi,

I figured out how to copy databases, but for some reason the primary key definitions aren't being transferred.

Anyone know how to do that easily?

I need to make annual archives.

PlantData exports to

PlantData2001
PlantData2002
PlantData2003

Etc.

Thanks,

RPG
 
BACKUP DATABASE PlantData TO DISK='e:\PlantData.bak'
--then
RESTORE DATABASE PlantData2001 FROM DISK='e:\PlantData.bak'
WITH RECOVERY

--or Try using the DTS 'COPY SQL OBJECTS TASK'
 
When restoring the database you'll need to use the WITH MOVE options to change the file names on the disk, so that you aren't trying to overwrite the production database.

Code:
backup database PlantData to disk='E:\PlantData.bak'
go
restore database PlantData2004 from disk='E;\PlantData.bak'
WITH MOVE 'PlantData_data' to 'd:\MSSQL\MSSQL\Data\PlantData2004_Data.mdf',
MOVE 'PlanData_Log' to 'd:\MSSQL\MSSQL\Data\PlantData2004_Log.ldf'

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top