I have parameter on sql , and I got an issue when it comes to this situation
declare @MonRemark varchar(10) = 's'
declare @ConfBy varchar(10)= 's'
declare @confstatus varchar(10)= 's'
declare @StatGD varchar(10)= ''
declare @StatGC varchar(50)= ''
declare @STATGTWO varchar(50)= ''
IF @MonRemark <> '' and (@ConfBy = '' OR @confstatus = '' and (@StatGD = '' or @StatGC = '' or @STATGTWO = '')) BEGIN
print 'a'
END
ELSE IF @ConfBy <> '' and (@MonRemark = '' OR @confstatus = '' AND (@StatGD = '' or @StatGC = '' or @STATGTWO = '')) BEGIN
print 'b'
END
ELSE IF @confstatus <> '' and @MonRemark = '' AND @ConfBy = '' AND (@StatGD = '' or @StatGC = '' or @STATGTWO = '') BEGIN
print 'c'
END
ELSE IF (@StatGD <> '' or @StatGC <> '' or @STATGTWO <> '') and @confstatus = '' AND @MonRemark = '' AND @ConfBy = '' BEGIN
print 'd'
END
ELSE BEGIN
print 'e'
END
if I filled parameter like what I write Above, I wish to get A , but it's always print E, is there any way to get A?
A, all the condition mustTRUEbut in there the results are likeIF TRUE and (FALSE and (TRUE)) BEGIN PRINT 'a'. Your condition returnFALSEbecause@ConfByand@confstatusare not NULL. Both@ConfByand@confstatushave valuesS