I have an Excel 2013 table in a sheet which is based on an MS Query into a SQL database. There are three parameters in the query, and values for those parameters are pulled from reference cells in another sheet. Here's how the parameters look in the query's SQL code:
AND (Date>=? AND Date<=?)
... and here are the parameter reference cells:
1 Facility CC
2 Start 03/30/15
3 Stop 04/04/15
4 SA Y
The Fac and the Date range parameters work just fine. But the SA parameter is giving me fits because the possible values in the SA field (defined as VARCHAR(1)) are either "Y" or NULL (blank). That is, I can put "Y" in Cell B4 above and all works well to return all records where SA = "Y".
But I can't figure out what to put in B4 to return only the records where SA = NULL: Making Cell B4 blank "works" but returns no records, and putting anything more than one character long in Cell B4 (e.g., <>'Y') returns a "String data, right truncation" error (presumably because it's VARCHAR(1)?). And, at times I would want all records (e.g., both SA = "Y" and SA = NULL).
This works, though, while keeping Cell B4 blank:
(SA=? OR SA IS NULL)
... to return only SA = NULL records. But with this I have no way to get just the SA = "Y" records, because putting "Y" in Cell B4 returns both SA = "Y and SA = NULL.
Am I missing something obvious?