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.
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 bkupgouse bkupgoselect * into backup_devices from sys.backup_devicesselect * from backup_devicesset ansi_nulls ondeclare @sql varchar(250)declare @bkup1 varchar(50)set @bkup1 =(select physical_name from backup_devices where name = 'backup1')print @bkup1declare @bkup2 varchar(50)set @bkup2 =(select physical_name from backup_devices where name = 'backup2')print @bkup2declare @bkup3 varchar(50)set @bkup3 =(select physical_name from backup_devices where name = 'backup3')print @bkup3if @bkup1 = null begin backup database DataCollection to disk = @bkup2 mirror to disk = @bkup3 with format print 'bkup1' endelseif @bkup2 = null begin backup database DataCollection to disk = @bkup1 mirror to disk = @bkup3 with format print 'bkup2' endelse backup database DataCollection to disk = @bkup1 mirror to disk = @bkup2 with format print 'bkup3'use mastergodrop database bkup |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-10-23 : 17:10:04
|
a first fast look:if @bkup1 = nullif @bkup1 is nulland also at bkup2 ,bkup3 WebfredNo, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|