Skip to Content
0
Former Member
Jul 01, 2011 at 06:54 AM

请问这个查询如果加了变量条件,就出错,用固定条件就不会,请问,问题出在哪里

20 Views

SELECT T0.[DocNum], T0.[DocStatus], T0.[DocDate], T0.[DocDueDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidSum], T0.[SlpCode], T1.[SlpName] FROM OINV T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode

WHERE

(T0.[CardCode] in (SELECT T5.[U_BPCode] FROM [dbo].[@UOBP] T5 inner join OUSR T6 on T5.U_UserCode=T6.user_code where T6.[USERID]=(SELECT 1)) AND (T0.DocDate >='[%1]' or '[%1]'='' ) and (T0.DocDate <='[%2]' or '[%2]'='') and (T0.[DocStatus]='[%3]' or '[%3]'='')

把[%1]或[%2] [%3]更改成固定条件,则能够正常查询

Edited by: Lang Wang on Jul 1, 2011 2:55 PM