Posts

Showing posts from December, 2009

POINT IN TIME RECOVERY

Below points are disscussing about point in time recovery of data in the Database 1)Create a database in the SQL Server Management Studio. Here i created a database named as New. 2)Create a table and Insert the data into that table. You can run the below query for creating table and insert the data into it. Use New GO CREATE TABLE TestForBackupNew (Sno INT IDENTITY(1,1),Valuess INT) GO DECLARE @I INT DECLARE @Count INT SET @I=1001 SET @Count=2000 WHILE(@I BEGIN INSERT INTO TestForBackupNew (Valuess) SELECT @I SELECT @I=@I+1 END SELECT * FROM TestForBackupNew 3)After Creating table and Inserting the data into it take FULL Backup and Transaction Log Backups. 4)Now delete the data from table. DELETE FROM TestForBackupNew WHERE SNO BETWEEN 1 AND 68---68 Rows affected 5)Change Database to Master 6)Restore the Database by choosing overwrite existing database. 7)Write Select Query and you can find the deleted data.

xp_logevent

DECLARE @@TABNAME varchar(30) DECLARE @@USERNAME varchar(30) DECLARE @@MESSAGE varchar(255) SET @@TABNAME = 'customers' SET @@USERNAME = USER_NAME() SELECT @@MESSAGE = 'The table ' + @@TABNAME + ' is not owned by the user ' + @@USERNAME + '.' PRINT @@MESSAGE USE master EXEC xp_logevent 610000, @@MESSAGE, ERROR(You can also give Information in the place of ERROR.) We can find this error in EventViewer like Controlpanel->AdministrativeTools->EventViewer.