Here is the code:
WHERE 1=1
AND TU.Auction_I IN (41, 42)
AND @StatePickupID = CASE
WHEN @StatePickupID IS NOT NULL
THEN (UP.TransportStateID = @StatePickupID)
END
AND @StateDropoffID = CASE
WHEN @StateDropoffID IS NOT NULL
THEN (UD.TransportStateID = @StateDropoffID)
END
So I only want to return records where UP.TransportStateID is equal to StatePickupID if it is not null, same thing for DropoffID. But I get a syntax error message where the equals sign is and I cannot find any other way to check for equality online. Any help or advice would be much appreciated.