I feel there must be a more efficient way to do this. I want to allow the caller to either pull ALL books, or books that are not hidden (see below)
if isnull(@ShowHiddenBooks, 0) = 1
begin
select
(long list of fields)
from
MyTable
where
MyField = @SomeField
end
else
begin
select
(long list of fields)
from
MyTable
where
MyField = @SomeField and
IsHidden = 0
end
Any thoughts?
Thanks!
Select *
from MyTable
where MyField = @SomeField and
(isHidden = 0 or @showHiddenBooks = 1)
This is equivqlent to:
select (long list of fields)
from
MyTable
where
MyField = @SomeField and
(IsHidden = 0 or isnull(@ShowHiddenBooks, 0) = 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With