Reputation: 5790
Depending on variable value my Where
condition should change
If @CustID <> 0
Then
Where SomeColumn = @BillID
Else
Where SomeColumn In (@BillID,0)
My Query:
Select *
From SomeTable
Where SomeColumn = (Case When @CustID <> 0 Then @BillID Else /* What to Write Here */ End)
Upvotes: 0
Views: 1626
Reputation: 3576
Here is the query you're looking for:
SELECT *
FROM SomeTable ST
WHERE (@CustID <> 0 AND ST.SomeColumn = @BillID)
OR (@CustID = 0 AND ST.SomeColumn IN (@BillID, 0))
Hope this will help.
Upvotes: 1