>>>>>I saw recently a thread on MSDN forum with the exact same message. I think it may be a bug in SQL Server 2005 which you hit. If you can not re-write the query, then I suggest to open a case with MS on this. You can also post this issue at MSDN forum. I suggest to post here
>>>>>
http://social.msdn.microsoft.com/Forums/en-US/transactsql/threads>>>>
>>>>Where can I see if I am on SP3?
>>>
>>>Run the script
http://berezniker.com/content/pages/sql/microsoft-sql-server/retrieving-sql-server-edition-version-and-service-pack-info>>
>>
>>Standard Edition 9.00.4053.00 SP3
>>
>>I had on other thought. How about concant the the query.
>>I notice if I used ?ldStartDate it adds parameters to the EXEC statement
>>but if I change it to '06/01/2010' it makes a select statement
>>
>>any thoughts on that one?
>
>I'm not sure why the same SQL works without parameters and doesn't work without. Try deleting the SQL Server cache (I need to check the command later).
>
>Run without parameters (with hardcoded values) to make sure it works without parameters. It still looks like a bug or something gone wrong.
I agree. Later in the program this queries works fine.
There is something going on the the Where OR clause that must be the issue
lcSQLCMD=[select ljob, matno, unitcost, burden, uomcost, uom, matquant, spoiled];
+[ FROM bbmatdc ];
+[ WHERE bbmatdc.ljob=?lcljob ];
+[ AND bbmatdc.costdate between ?ldstartdate and ?ldenddate]