/* Single selection parameters should be used when dealing with one value only: - in WHERE clauses - in CASE clauses - in GROUP BY and ORDER BY a specific column - in ISNULL or COALESCE - in UPDATE, DELETE statements - in LIKE statements In these cases we include quotes as the parameter placeholder will get replaced by the selected value. In the following scenario CardCode and AcctCode are single selection parameters. Notice the quotes around the parameters: */ SELECT DISTINCT TOP 10 T0.[ItemCode] ,T0.[Dscription] ,SUM(Cast(T0.[Quantity] AS INT)) AS Quantity FROM INV1 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[CardCode] = '[%CardCode]' OR T0.AcctCode LIKE '%[%AcctCode]%' /* Given the selection CardCode = C10000 and AcctCode = C20000 the WHERE clause becomes WHERE T1.[CardCode] = 'C10000' OR T0.AcctCode LIKE '%C20000%' */ GROUP BY T0.ItemCode, T0.Dscription /* Multiple selection mode should be used when dealing with more than one value: - in IN statements In these cases the quotes are automatically included to form the specific IN synthax, that requires each value to be separated by commas In the following scenario CardCode is a multiple selection parameter. Notice that there are no quotes around the parameter. */ SELECT DISTINCT TOP 10 T0.[ItemCode] ,T0.[Dscription] ,SUM(Cast(T0.[Quantity] AS INT)) AS Quantity FROM INV1 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[CardCode] IN ([%CardCode]) /* Given the selection 'C10000','C20000' the WHERE clause becomes WHERE T1.[CardCode] IN ('C10000','C20000') */ GROUP BY T0.ItemCode, T0.Dscription