SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 
        
Home       Members    Calendar    Who's On



SQLX 2005 - Preserve copy under a new name Expand / Collapse
Author
Message
Posted Friday, June 26, 2009 4:44 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 29, 2009 12:25 PM
Points: 5, Visits: 12
Le's say the DB is named "Reports". I want to preserve and be able to access each year's records under a new name, such as "Reports2009". I can rename the DB in SQL Server Management, but I still have only one DB, not two. Thanks for your help.
Post #742526
Posted Friday, June 26, 2009 4:49 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:26 PM
Points: 1,698, Visits: 2,268
bytesizedata (6/26/2009)
Le's say the DB is named "Reports". I want to preserve and be able to access each year's records under a new name, such as "Reports2009". I can rename the DB in SQL Server Management, but I still have only one DB, not two. Thanks for your help.


You can rename the db (sp_renamedb??) but in your case u need to archive ur data to new databases for each year may be..





Pradeep Singh
Post #742531
Posted Friday, June 26, 2009 4:52 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 2:06 AM
Points: 274, Visits: 504
Backup the database
Backup database DB_name to disk='path+filename.bak'

Restore using different name
Reastore database DB_New_name from disk='path+filename.bak'
with move datafile_name='newfilepath', logfile_name='newfilepath'



- Roshan Joe
============================
"We can't solve problems by using the same kind of thinking we used when we created them" Einstein



Automate drive space monitoring for all production servers

Script to find latest backups for all databases
Post #742535
Posted Friday, June 26, 2009 6:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 29, 2009 12:25 PM
Points: 5, Visits: 12
The Backup command executed OK. However, the Restore command

Restore database Records2009 from disk='path+filename.bak' with move datafile_name='C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Data\Records2009', logfile_name='C:\Program Files]Microsoft SQL Server\MSSQL.2\MSSQL\Data\Records2009'

resulted in the error messages "Incorrrect syntax near 'datafile_name'

Changing the above to MSSQL.1 also resulted in the same error message.
Post #742594
Posted Friday, June 26, 2009 6:26 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 2:06 AM
Points: 274, Visits: 504
you should replace datafile_name and logfile_name with there logical file name in single qoutes. Also put the correct backup path.

To find out the file names execute.

Restore filelistonly from disk='backupfile'



- Roshan Joe
============================
"We can't solve problems by using the same kind of thinking we used when we created them" Einstein



Automate drive space monitoring for all production servers

Script to find latest backups for all databases
Post #742602
Posted Friday, June 26, 2009 6:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 29, 2009 12:25 PM
Points: 5, Visits: 12
The command

Restore filelistonly from disk='backupfile' gave me the logical file names "Records" and "Records_log"

Executing

Restore database Records2009 from disk='path+filename.bak' with move datafile_name='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records', logfile_name='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records_log'

continued to give the error message

"Incorrect syntax near 'datafile_name'"
I tried using MSSQL.1 and MSSQL.2
Post #742623
Posted Friday, June 26, 2009 7:20 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:26 PM
Points: 1,698, Visits: 2,268
bytesizedata (6/26/2009)
The command

Restore filelistonly from disk='backupfile' gave me the logical file names "Records" and "Records_log"

Executing

Restore database Records2009 from disk='path+filename.bak' with move datafile_name='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records', logfile_name='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records_log'

continued to give the error message

"Incorrect syntax near 'datafile_name'"
I tried using MSSQL.1 and MSSQL.2


Restore database Records2009 from disk='BackupFilePath\filename.bak' with move 
'records'='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records',
'records_log'='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records_log'

replace the portion in the bold with actual path of your backup file.


EDIT - Corrected the code.





Pradeep Singh
Post #742656
Posted Friday, June 26, 2009 7:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 29, 2009 12:25 PM
Points: 5, Visits: 12
Now I get the error message "Incorrect syntax near '='" I assume the error is at the first instance:

'Records'='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Records', etc.

Question: Don't I want this archived, renamed DB stored in folder MSSQL.2\MSSQL\Data? If stored in folder MSSQL.1, what happens to the existing DB? Or, is the renamed DB automatically put in its own folder?
Post #742674
Posted Friday, June 26, 2009 8:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 29, 2009 12:25 PM
Points: 5, Visits: 12
I finally figured out how to restore the DB under a new name by using SQL Server Management's Tasks option. Not very intuitive, is it.
Thanks for your help.
Post #742725
« Prev Topic | Next Topic »


Permissions Expand / Collapse