I have the following TSQL if statments:
IF @sExch = '01' AND @MonthCurr = 1
delete from CBOTPrelim where CBOTPrelim.FirmNumber = @sFirm and CBOTPrelim.YearMonth = @ymprev
else
delete from CBOTPrelim where CBOTPrelim.FirmNumber = @sFirm and CBOTPrelim.YearMonth = @ym
IF @sExch = '02' AND @MonthCurr = 1
delete from CMEPrelim where CMEPrelim.FirmNumber = @sFirm and CMEPrelim.YearMonth = @ymprev
else
delete from CMEPrelim where CMEPrelim.FirmNumber = @sFirm and CMEPrelim.YearMonth = @ym
when I import a file with a @sFirm of 177 and @sExch of 01 the data for the firm and exch is erased from both the CBOTPrelim table and the CMEPrelim table and entered into the CBOTPrelim table. If I then import firm 177 and exch of 02 the above code then erases the information in CBOTPrelim and CMEPrelim table and enters the information into the CMEPrelim table. I just want the information deleted from the CBOTPrelim table if the exch is 01 or the CMEPrelim table if the exch is 02. What am I doing wrong that I am not seeing here? Thanks for all help in advance.
Dave
IF @sExch = '01' AND @MonthCurr = 1
delete from CBOTPrelim where CBOTPrelim.FirmNumber = @sFirm and CBOTPrelim.YearMonth = @ymprev
else
delete from CBOTPrelim where CBOTPrelim.FirmNumber = @sFirm and CBOTPrelim.YearMonth = @ym
IF @sExch = '02' AND @MonthCurr = 1
delete from CMEPrelim where CMEPrelim.FirmNumber = @sFirm and CMEPrelim.YearMonth = @ymprev
else
delete from CMEPrelim where CMEPrelim.FirmNumber = @sFirm and CMEPrelim.YearMonth = @ym
when I import a file with a @sFirm of 177 and @sExch of 01 the data for the firm and exch is erased from both the CBOTPrelim table and the CMEPrelim table and entered into the CBOTPrelim table. If I then import firm 177 and exch of 02 the above code then erases the information in CBOTPrelim and CMEPrelim table and enters the information into the CMEPrelim table. I just want the information deleted from the CBOTPrelim table if the exch is 01 or the CMEPrelim table if the exch is 02. What am I doing wrong that I am not seeing here? Thanks for all help in advance.
Dave