Restore Specific Row Set Accidentally Deleted From A Table
Feb 2, 2004
Hi!
Is there any way I can resore a specified set of deleted rows from a table? Most of these rows were created during the course of the day, but at the end a user deleted them accidentally. My latest full backup is from last night, but if I restore it, it will overwrite many other tables that already have correct informaiton entered during the day. Is there any to roll back only the transaction with which the rows were deleted?
Is there any way I can resore a specified set of deleted rows from a table? Most of these rows were created during the course of the day, but at the end of it a user deleted them accidentally. My latest full backup is from last night, but if I restore it, it will overwrite many other tables that already have correct informaiton entered during the day. Is there any to roll back only the transaction with which the rows were deleted?
hi there i am using .net framework 1.1 with SQL 2000 . i want the data in table to get deleted automatically after 30 days of inserting data. so how do i achieve this?
The setup is 3 sql 2000 servers, one with a number of publications, and two with transactional pull subscriptions.
The publications were accidentally deleted from the primary server when replication was removed from an older server that unfortunately had been cnamed to the primary server.
The subscriber servers now error "the subscription does not exist".
I had thought restoring the master and msdb on the publisher would bring the publications back but this has not happened. There are good backups of all the system and user databases on the publisher available, but not the scripts that created the publications for replication. Can anyone suggest how or what to restore to get the publications back on the primary server so we can restart replication?
Thank You!
[edit] It also may be worth noting that the publisher is it's own distributor in this scenario.
First, let me say that I have already reviewed information posted by experts within the chat area.
Someone completely deleted my SQL Server 7 database. I retrieved the .LDF and .MDF files from a network backup. Now I am trying to attach the database. I have tried this without creating an instance of the database by using the attach stored procedure to attache the .LDF and .MDF files I retrieved from the network backup. Also, I have tried it by creating an instance of the database and doing a detach of the newly created db .LDF and .MDF files and an attach of the .LDF and .MDF files I retrieved from the network backup. Neither of these approaches have worked.
Here is what I have tried in the Query Analyzer, but to no avail:
For the following example, I created a database instance called 'qarun_diamond_48_brett' with brand new .ldf and .mdf files and then tried to detach and then attach the .ldf and .mdf files from the network backup:
use master go sp_detach_db 'qarun_diamond_48_brett', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett_log.ldf'
I tried the following attaches of the retrieved/recoverd .ldf and .mdf from the network to the newly created db instance. That didn't work, so I tried attaching to a db that had not yet been created.
use master go sp_attach_db 'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2_log.ldf'
Message: Server: Msg 1801, Level 16, State 3, Line 1 Database 'qarun_diamond_48_brett' already exists.
If I use a different db name I get the following error: Server: Msg 5105, Level 16, State 13, Line 1 Device activation error. The physical file name 'qarun_diamond_48_brett' may be incorrect.
use master go sp_attach_db 'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2.mdf'
Message: Server: Msg 1801, Level 16, State 3, Line 1 Database 'qarun_diamond_48_brett' already exists.
I have also tried these statements wtih the EXEC sp_attach_db and EXEC sp_detach_db commands from within the Master db in Query Analyzer.
I want to ship 500,000 aged transactions each night to an archive table and delete them from their source table in one or more logical units of work (LUW). Each row is approx 60 bytes and there is only one non clustered index on the source table presently.
I'm trying to weigh the pros and cons of 3 alternatives. One of them would basically insert the non-aged rows into tempdb, ship the aged records, truncate the table and then insert the tempdb records back into their source all in the same LUW.
For this alternative, I'd at least like to turn off logging when the records get inserted into tempdb as I dont see any value in logging that part of the activity. Is this possible?
Scenerio: Its 3pm and a user comes to me and says, she's deleted an invoice with many associated items. I know the affected tables (foreign keys) and I have last nights backup of the db. However I don't want restore the entire db back from last night just the deleted invoice record/s. What is the best practice procedure for accomplishing this?
i have been doing tests and i cannot manage to do this. here is what i have done and am trying to do:
I created a full backup of the adventureworks database
I made some updates to tables.
I created a differential backup.
I done an update update to another table, dropped a table, and done another update.
Lets say in a production envrionment i just realised the table was dropped and i wanted to go to the transaction just before the table was dropped. is this possible, or are all transactions in the log going to be lost? All i have found remotely related to this are marked transactions, but they are not what i am looking for. i want a list of transactions in the log and be able to select one as the backup point ( via SSMS or TSQL). i am not looking for a point in time restore.
In SQL 2008, there is a way to backup a database, but specify the tables backed up, and, during the restore on the destination server, restore only those tables in the database?
I have an SQL .bak file and I would only like to restore specific columns as one of the columns is a free text field and is substantially increasing the size of the file. I can't restore it due to disk space constraints so dropping the column isn't possible if I can't get the table into a database locally.
Someone stumped me with a question the other day. And I was wanting to know if my answer was accurate.
They were worried about locking up SQLServer with too many queries when accessing it through a web page.
I haven't actually had this problem with any of the stuff I have done. And I never had it happen way back when I was just doing database stuff either.
I suppose this happens when a query is run that the stored procedure conflict and end up getting locked up because neither query can finish their process until the other lets the tables go. So one way to avoid this is to make sure dangerous queries are never done through the web interface. Right can do but and the other thing I was wondering about it how they balance queries on the server. I know about testing the equipment to find out which queries work the best and how to create a good normalized database you know good structure etc. (is this why I never had this problem or is it more because I did have a ton of different people accessing the data all at once -- but if they are accessing it in a controlled fashion then whats the worry right?)
Since I don't know how to cause this exactly-- I don't know how to prevent it.
Hi, I have accidentally disabled the Administrator account in Sql Server 2005 (Douh!) on my clients server (double Dough!) & now I can login to enable it.
The <BuiltInAdministartors> account is still active, The accout i disabled was <DomainAdministrator> (forgot I was logined via Terminal server).
I would like to access the data inserted or deleted within a trigger. however the built-in tables -- inserted and deleted --- are not accessible. anyone knows why? And is there any other way to do this?
Is there a way to check who has deleted records from my SQL tables? I asked because I notice records keep disappearing from my tables recently for no reason. The DB is only accessible by a few IT staff. Business users have no direct access to it so they can't do any harm and there is no application that update these record missing tables.
I don't need to know the exact records that have been removed. I need info on who has made a deletion activity on which table, date and time is good enough.
Hi all I would like to know if its possible to "Save" records when they get deleted. For example: I have a table, tblUsers, with coulmns, UserID, Name, Surname, etc... In VWD I've created a GridView which shows everything on a webpage. I've also added a confirm return('Are you sure you want to delete the user?') option in OnClientClick field. What i want to achieve is, have some sort of log file, or log table if you want to call it that, of which users has been deleted by the end user. So, in later stages, i can see who deleted who, when, where, etc... - by building a report or view. All this should go to a seperate database or seperate table, it doesnt really matter. My delete query:DELETE FROM [tblUsers] WHERE [UserID] = @UserID
It happened accidently that we deleted records from a table in SQL server 2005 DB. We never took a full backup of the DB till then. Is there any way that we can recover the deleted records. Logs files are still present. ( *mdf and *ldf ).
Is there way to undelete deleted records from a table? - For security reasons I need to delete records without removing them out of the database.
In other words: target is to design a procedure to delete records only logical.
I had the idea to use a field, saying record is deleted or not. This field would control if data is hidden (logical deleted) or not. To undelete a record, only this field would change its state.
But it becomes difficult if you have many FK to logical deleted data.
I have a table in which there is a column of type identity(1,1),in the same table i have bulk data, and i have deleted a row from my table, so now i want to reuse that same Id again, how to do that.
Can any one tell me ..is there any restriction on the total number of records that can be added to a table ( SQL Server 2005) .Because .. i added 100 records to a table through my program..but i was able to c ..only the last 20 records which is being inserted..can any one tellme any way to increase the total number of records..
pls..help me..solution is required immediately.........
I have a stored procedure that's running a little slower than I would like. I've executed the stored proc in QA and looked at the execution plan and it looks like the problem is in a trigger on one of the updated tables. The update on this table is affecting one row (I've specified the entire unique primary key, so I know this to be the case). Within my trigger there is some code to save an audit trail of the data. One of these statements does an update of the history table based on the inserted and deleted tables. For some reason this is taking 11.89% of the batch cost (MUCH more than any other statement) and within this statement 50% of the cost is for a table scan on inserted and 50% is for a table scan on deleted. These pseudo-tables should only contain one record each though.
Any ideas why this would be causing such a problem? I've included a simplified version of the update below. The "or" statements actually continue for all columns in the table. The same trigger template is used for all tables in the database and none of the others seem to exhibit this behavior as far as I can tell.
Thanks for any help! -Tom.
UPDATE H_MyTable SET HIST_END_DT = @tran_date FROM H_MyTable his INNER JOIN deleted del ON (his.PrimaryKey1 = del.PrimaryKey1) and (his.PrimaryKey2 = del.PrimaryKey2) INNER JOIN inserted ins ON (his.PrimaryKey1 = ins.PrimaryKey1) and (his.PrimaryKey2 = ins.PrimaryKey2) WHERE (his.HIST_END_DT is null) and ((IsNull(del.PrimaryKey1, -918273645) <> IsNull(ins.PrimaryKey1, -918273645)) or (IsNull(del.PrimaryKey2, -918273645) <> IsNull(ins.PrimaryKey2, -918273645)) or (IsNull(del.Column3, -918273645) <> IsNull(ins.Column3, -918273645)))
I am having a hard time understanding triggers. My goal is to put a trigger on table x where records are UPDATED or DELETED. When this trigger fires I need to take the record ID and put the ID modified record into table y with the date modified. so basically logging the recordid changed with the getDate()
I don't quite understand how to get the rowid of the modified record.
Hi there,Could somebody post some simple example how one can refer toa column in the 'deleted' temporary table within a trigger definition ?Should the 'deleted' and 'inserted' temp tables be declared, or they are'implied' ?I keep having this msg when trying to create a trigger"The column prefix 'deleted' does not match with a table name or alias nameused in the query"Thanks for your inputs,Eddy.