Search code examples
sqlsql-serversql-server-2008ssrs-2008ssrs-2012

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 UNION SELECT local FROM tbl

Thanks everyone!


Solution

  • You could just use an or:

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

    Or

    select *
    from tbl
    where @Local IN (Local, 2)