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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Backup

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2013-06-06 : 02:58:55
Hi

I have written this procedure to take Backup , it works .

ALTER PROCEDURE [dbo].[SpBackup] @dbname varchar(50) , @path varchar(256) AS BEGIN DECLARE @filename VARCHAR(256) DECLARE @filedate VARCHAR(20) SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) DECLARE db_cursor CURSOR FOR SELECT name From master.dbo.sysdatabases WHERE name IN (@dbname) OPEN db_cursor FETCH NEXT FROM db_cursor INTO @dbname WHILE @@FETCH_STATUS = 0 BEGIN SET @fileName = @path + @dbname + '_' + @fileDate + '.BAK' BACKUP DATABASE @dbname TO DISK = @fileName FETCH NEXT FROM db_cursor INTO @dbname End Close db_cursor DEALLOCATE db_cursor End

But when i am restoring this Backup it gives error "The tail of the log of the Database "Test" has not been backed up.

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-06-06 : 04:11:51
This is just SQL Server's way of telling you that there are log records in the transaction log that have not been backed up. If the current transaction log can be discarded, you can use the REPLACE option to tell SQL Server to ignore the current transaction log e.g.

RESTORE DATABASE AdventureWorks FROM DISK = 'G:\Backups\AdventureWorks_full.bak' WITH REPLACE

See here: http://www.sqlbackuprestore.com/backingupthetail.htm


Too old to Rock'n'Roll too young to die.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-06-06 : 10:41:57
To check the backup history - such as trying to assess LSNs etc , use http://www.sqlserver-dba.com/2012/06/display-sql-backup-history-for-a-single-database.html
You can assess which backup to restore for the relevant restore point

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2013-06-07 : 00:48:18
Hi

What should i change in the above Stored Procedure . Do i need to make any changes .

Thanks
Go to Top of Page
   

- Advertisement -