Database yedeğini prosedürle alabilirsin
/****** Object: StoredProcedure [dbo].[BACKUPDB] Script Date: 02/11/2013 20:41:41 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE procedure [dbo].[DB_YEDEKLE]
AS
declare @user smallint, @TbAcc smallint, @Acc smallint
select @user = COUNT (struserId) from USERDATA
select @TbAcc = COUNT (struserId) from USERDATA
select @Acc = COUNT (struserId) from USERDATA
IF @user > 0 and @TbAcc > 0 and @Acc > 0
BEGIN
declare @location varchar(120)
set @location = N'C:\Backup\DATABASE YEDEK '+replace(str(year(getdate()))+'-'+str(month(getdate()))+'-'+str(day(getdate())),' ', '')+'.bak'
BACKUP DATABASE [dbadi] TO DISK = @location WITH NOFORMAT, INIT, NAME = N'Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'dbadi' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'dbadi' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''dbadi'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM DISK = @location WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
print "Database yedegi `C:\Bakcup` klasörüne alındı. Eğer hata aldıysanız C nin içine Backup Adında klasör oluşturup tekrar deneyin. Pvphosting.net"
END
ELSE IF @user = 0 and @TbAcc = 0 and @Acc = 0
RETURN
Kullanımı ; exec db_yedekle
NOT : C nin içersine "Backup" adında bir klasör oluşturun. Prosedür otomatik olarak "DATABASE YEDEK-YIL-AY-GÜN.bak" şeklinde yedek alacaktır