Friday, February 24, 2012

How to use a Wildcard with the value for the parameter?

I have a report that selects certain records based on what the user enters for the parameter but I'm trying to allow the user to enter a wildcard and show the relevant records. I used like and had the user add an * or even a % but it still returns nothing. Records are returned only when the user enters the full value with no wildcards. Help.

SELECT DISTINCT
PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID, PDFBM.REQUIRED_QTY, ICFPM.PART_DESC, ICFPM.DWG_REV, ICFPM.PENDING_ECN,
dbo.ICFSS.STORES_CODE, dbo.ICFSS.STOCK_LOCATION
FROM dbo.ICFPM ICFPM INNER JOIN
dbo.PDFBM PDFBM ON ICFPM.PART_ID = PDFBM.ASSEMBLY_ID INNER JOIN
dbo.ICFSS ON ICFPM.PART_ID = dbo.ICFSS.PART_ID
WHERE (PDFBM.COMPONENT_ID LIKE @.componentid) AND (PDFBM.ASSEMBLY_ID LIKE '350%')
ORDER BY PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID

A

I'm not sure but try converting the query to a dynamic query:

="SELECT DISTINCT
PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID, PDFBM.REQUIRED_QTY, ICFPM.PART_DESC, ICFPM.DWG_REV, ICFPM.PENDING_ECN,
dbo.ICFSS.STORES_CODE, dbo.ICFSS.STOCK_LOCATION
FROM dbo.ICFPM ICFPM INNER JOIN
dbo.PDFBM PDFBM ON ICFPM.PART_ID = PDFBM.ASSEMBLY_ID INNER JOIN
dbo.ICFSS ON ICFPM.PART_ID = dbo.ICFSS.PART_ID
WHERE (PDFBM.COMPONENT_ID LIKE '" + Parameters!componentid.Value + "') AND (PDFBM.ASSEMBLY_ID LIKE '350%')
ORDER BY PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID"

Regards,

Telmo Moreira

|||

try:

LIKE @.parameter + '%')

drop the user adding the wildcard char

No comments:

Post a Comment