We’ve got a query on SAP which has some potential to cause problems.
SELECT T2.[DistNumber], T1.[ItemCode], T0.[ItemName], T0.[CardName], T2.[InDate], T1.[Quantity] FROM OITL T0 INNER JOIN ITL1 T1 ON T0.[LogEntry] = T1.[LogEntry], OBTN T2 WHERE T2.[DistNumber] =[%0]
Somebody put the wildcard (%) into the prompt and of course everything got clogged up.
Is there a way to disallow the wildcard in the WHERE, maybe with a CASE or something? The only other alternative I could come up with was to only select the top 1000 or something but I wondered if there was a better way.
Many thanks.
Advertisement
Answer
Can you remove it in WHERE clause something like below?
SELECT T2.[DistNumber], T1.[ItemCode], T0.[ItemName], T0.[CardName], T2.[InDate], T1.[Quantity] FROM OITL T0 INNER JOIN ITL1 T1 ON T0.[LogEntry] = T1.[LogEntry], OBTN T2 WHERE T2.[DistNumber] =replace([%0],'%','')