- Joined
- Dec 7, 2006
- Messages
- 250
- Reaction score
- 2
here ya go:
Don't forget to change @location.
this proc is usefull because u can easily attach it to a php file, and make something like a: *Backup Tool*
Code:
USE [KN_online]
GO
/****** Object: StoredProcedure [dbo].[BackupDB] Script Date: 08/18/2008 09:47:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[BackupDB]
as
declare @location varchar(120)
set @location = N'c:\dbbackups\SERVERDB.bak'
BACKUP DATABASE [Kn_Online] TO DISK = @location WITH NOFORMAT, INIT, NAME = N'KO-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'Kn_Online' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'Kn_Online' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''Kn_Online'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM DISK = @location WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
Don't forget to change @location.
this proc is usefull because u can easily attach it to a php file, and make something like a: *Backup Tool*