dran dran - 3 years ago 157
SQL Question

Selecting All Values where field type is tinyint

I am finishing a report where I was asked to include a "ALL" choice so that all the records will show. The scenario is that the field (Local) contains 0 and 1 only for True and False respectively. The query I wrote takes forever to load the report when all is selected, is there a better way to do this? Below is the query I have for show "All"

SELECT '2' AS Local
SELECT local
FROM tbl

Thanks everyone!

Answer Source

You could just use an or:

select *
from tbl
where (Local = @Local or @Local = 2)


select *
from tbl
where @Local IN (Local, 2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download