I've discovered a bit more and it seems to deal with the DECLARE @<variable> statement. For example:
DECLARE @FOO varchar(100) = '123456' select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE @FOO and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R'
That does not work in LabVIEW or TestStand but it does work in other environments. Rewriting, the following works in LabVIEW
select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE '%s' and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R'
and TestStand
"select BaseID, LotID, SubID, SplitID, InstanceID from MyTable where DrawingNumber LIKE '" + Locals.PartNumber + "' and (LotID = 'EWR' or LotID = 'RWK') and Status = 'R' "
This indicates to me that somewhere between getting the string of the SQL query and actually giving that string to the SQL Server, something was altered. I tried escaping the @ string but that didn't help. It appears on some ni.com forums that they have issues with DECLARE but I'm unsure as to the degree. (http://forums.ni.com/t5/LabVIEW/SQL-Query-Works-in-MS-SQL-Server-2008-but-not-when-using/td-p/2151492)
I could use the Create Parameterized Query and Set Parameter Values VIs but that seems like a work around to translate a SQL query which typically works for use with LabVIEW. I'm trying to have one text document filled with queries that any environment can pull from.