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 2005 Forums
 SQL Server Administration (2005)
 help with Backup script

Author  Topic 

dbist
Yak Posting Veteran

52 Posts

Posted - 2008-10-23 : 16:54:14
Hello all, I am not a developer but I suspect that my script never goes to the If statement, please help if you can:

create database bkup
go
use bkup
go
select * into backup_devices from sys.backup_devices
select * from backup_devices
set ansi_nulls on
declare @sql varchar(250)
declare @bkup1 varchar(50)
set @bkup1 =(select physical_name from backup_devices where name = 'backup1')
print @bkup1
declare @bkup2 varchar(50)
set @bkup2 =(select physical_name from backup_devices where name = 'backup2')
print @bkup2
declare @bkup3 varchar(50)
set @bkup3 =(select physical_name from backup_devices where name = 'backup3')
print @bkup3

if @bkup1 = null
begin
backup database DataCollection to disk = @bkup2
mirror to disk = @bkup3 with format
print 'bkup1'
end
else
if @bkup2 = null
begin
backup database DataCollection to disk = @bkup1
mirror to disk = @bkup3 with format
print 'bkup2'
end
else
backup database DataCollection to disk = @bkup1
mirror to disk = @bkup2 with format
print 'bkup3'

use master
go
drop database bkup

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-23 : 17:10:04
a first fast look:
if @bkup1 = null
if @bkup1 is null

and also at bkup2 ,bkup3

Webfred

No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -