30-01-2020, Saat: 15:54
(Son Düzenleme: 19-03-2020, Saat: 13:42, Düzenleyen: adelphiforumz.)
MSSQL için Network üzerinde bulunan bir alan Backup ve Restore işlemleri ile uğraşıyordum sonunda hallettim
Belki birininde ihtiyacı olur diye burada da kalsın istedim.
Belki birininde ihtiyacı olur diye burada da kalsın istedim.
Declare @prevAdvancedOptions int Declare @prevXpCmdshell int Select @prevAdvancedOptions = cast(value_in_use as int) from sys.configurations where name = 'show advanced options' Select @prevXpCmdshell = cast(value_in_use as int) from sys.configurations where name = 'xp_cmdshell' if (@prevAdvancedOptions = 0) begin exec sp_configure 'show advanced options', 1 WaitFor Delay '00:00:01.000' Reconfigure --Update currently configured values for advanced options. WaitFor Delay '00:00:01.000' end -- To enable xp_cmdshell if (@prevXpCmdshell = 0) begin exec sp_configure 'xp_cmdshell', 1 WaitFor Delay '00:00:01.000' Reconfigure --Update currently configured values for advanced options. WaitFor Delay '00:00:01.000' end Exec xp_cmdshell 'NET USE T:\\Server\SqlTest Password /USER: Domain\UseName' WaitFor Delay '00:00:01.000' Exec XP_CMDSHELL 'Dir T:' Use [master] Backup DATABASE [DBFileName] TO DISK = N'T:\SQLDB\XFile.bak' WITH NOFORMAT, NOINIT, Name = N'XFile-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 Use [master] Restore Database [TG_Lojistik] From Disk = N'T:\SQLDB\XFile.bak' With File = 1, Move N'DBFileName' To N'T:\SQLDB\XFile.mdf', Move N'DBFileName_log' To N'T:\SQLDB\XFile_log.ldf', NoUnload, Stats = 5 if (@prevXpCmdshell = 0) begin exec sp_configure 'xp_cmdshell', 0 WaitFor Delay '00:00:01.000' Reconfigure --Update currently configured values for advanced options. WaitFor Delay '00:00:01.000' end If (@prevAdvancedOptions = 0) begin exec sp_configure 'show advanced options', 0 WaitFor Delay '00:00:01.000' Reconfigure --Update currently configured values for advanced options. WaitFor Delay '00:00:01.000' end Go
Bu dünyada kendine sakladığın bilgi ahirette işine yaramaz.