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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database backup

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
US
I accidently delete a record in a table. Is there anyway I can retreive this record? This db is backed-up twice a day. I have it's .BAK file.

Thanks
 

Restore that backup as a different database and copy which ever row you deleted from the new database to the existing database

And delete the newly restore database

ex.

restore database newdatabase from disk = 'd:\x.bak'
with replace,
move 'x_data' to 'd:\mssql\data\x_data.mdf',
move 'x_log' to 'd:\mssql\data\x_log.ldf',

use newdatabase
go
insert into existing_database.dbo.table1 select * from newdatabase.dbo.table1 where id = xxx


(where xxx is the deleted row)


 
Thank you so much for your help! What are x_data and x_log?
 
move 'x_data' to 'd:\mssql\data\x_data.mdf'

where x is the database name?
 
Oh...got it now... x is the bak file name. Thanks again.
 
I got syntax error:

restore school-class school-class from disk = 'E:\sql\backup\school-class_db_200307260600.BAK'
with replace,
move 'school-class_db_200307260600_data' to 'd:\sql\data\school-class_db_200307260600_data.mdf',
move 'school-class_db_200307260600_log' to 'd:\sql\data\event-pass_db_200307260600_log.ldf',

use school-class-bak
go
insert into school-class.dbo.customer_order select * from school-class-bak.dbo.class_id where id = 007

-----here is the err msg
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.

 
I got the typo in my new database name. Should be read: school-class-bak.
 
Oh... "database" is keyword.

Anyways, I can restore the database using Enterprise Manager. Thanks ClaireHsu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top