Reputation: 166
I have a bit parameter
@IsInRetry
If it is false I have to set the where condition to
attempts = 0
else if it is true I have to set the where condition to
attempts > 0
How could this be done?
Upvotes: 1
Views: 79
Reputation: 655
Try this, should work also for negative attempts :-)
@IsInRetry = (attempts > 0)
Greetings.
Upvotes: 0
Reputation: 3844
Try this:
WHERE (attempts = @IsInRetry or (@IsInRetry = 1 and attempts > 0))
Upvotes: 0
Reputation: 2624
This:
if @IsInRetry = 0x0
BEGIN
SELECT * FROM dbo.tbl
WHERE attempts = 0
END
ELSE
BEGIN
SELECT * FROM dbo.tbl
WHERE attempts = 1
END
Upvotes: -1
Reputation: 25763
Try this way:
( (@IsInRetry = 0 and attempts = 0) or (@IsInRetry = 1 and attempts > 0) )
Upvotes: 4