PDA

View Full Version : excel - sql query - parameters check for empty value



nicole282
2020-06-04, 12:09 AM
I am trying to create an excel report using sql queries.


I have a drop down box (generated via a sql query) that loads another report based on the input value.
Drop down box code:
Select null as State
UNION
Select state from tbl_States


This query generates a dropdown of available states. I added the null to allow for an empty string to return all records.


Query for Report:
Select columns
from tables
where tbl_states.State = ? or isnull(?,'') = ''


I am receiving an error: string data, right truncation


any ideas how else to write this to get the results I need?
I don't have access to create stored procedures or anything...