Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Wrong Query Fired

Author  Topic 

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-04-19 : 01:00:33
By Database is heavily used , we use Transaction log backups ever 10 minuts, now someone fired a wrong query , that updated a particular table , the DB is still in use, there are some users working on it , I cant get the DB offline , what can I do to correct the mistake , please advice.

Kristen
Test

22859 Posts

Posted - 2006-04-19 : 01:09:55
Restore to point-in-time [just before the accident] to a DIFFERENT, NEW, (temporary) DATABASE. Then update the original database data by joining it to the same table in the new database.

Your UPDATE will have to be selective to only update what was broken, and not what might have been changed subsequently.

Something like this:

UPDATE U
SET TheDamagedColumn = S.TheDamagedColumn
FROM MyLiveDatabase.dbo.MyTable AS U
JOIN MyTEMPDatabase.dbo.MyTable AS S
ON S.MyPK = U.MyPK
WHERE ... criteria for what is a damaged record! ...

Kristen
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2006-04-19 : 01:22:32
Damn, I read that as "wrong query, fired"





Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-04-19 : 02:13:24
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-19 : 02:15:33
I guess somebody that fired the wrong query will be fired



KH


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-19 : 02:23:01
If some records are deleted then you may need to insert them from backup table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2006-04-19 : 02:27:09
quote:
Originally posted by madhivanan

If some records are deleted then you may need to insert them from backup table

Madhivanan

Failing to plan is Planning to fail



Genius!

Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-19 : 02:32:47
quote:
Originally posted by Merkin

quote:
Originally posted by madhivanan

If some records are deleted then you may need to insert them from backup table

Madhivanan

Failing to plan is Planning to fail



Genius!

Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson


Thanks. I am happy to get appreciation from you

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -