Skip to Content
author's profile photo Former Member
Former Member

Query Parameter Question

I'm trying to add a parameter range to an existing query but I'm never prompted to enter a parameter, I just get 0 records returned- I'm sure I'm missing something 😊, here is the query-

SELECT TOP 100 PERCENT dbo.OITM.ItemCode AS Part, dbo.OITM.ItemName AS Description, dbo.OITM.OnHand, dbo.OITM.IsCommited AS Allocated,

dbo.OITM.U_toOrdPt AS OrdPt, dbo.OITM.OnHand - dbo.OITM.IsCommited AS Available, dbo.OITM.OnOrder,

CASE WHEN dbo._FSsalestots.YTD IS NULL OR

dbo._FSsalestots.YTD LIKE ' ' THEN dbo.[_YTD Sales].SAPYTD WHEN dbo.[_YTD Sales].SAPYTD IS NULL OR

dbo.[_YTD Sales].SAPYTD LIKE ' ' THEN dbo._FSsalestots.YTD ELSE dbo._FSsalestots.YTD + dbo.[_YTD Sales].SAPYTD END AS YTD,

dbo._FSsalestots.PYTD, CASE WHEN U_toPhased = 'Y' THEN 'PHASED' ELSE NULL END AS Phased

FROM dbo.OITM INNER JOIN

dbo._ItemMaster ON dbo.OITM.ItemCode = dbo._ItemMaster.[FOURTH SHIFT DATA] INNER JOIN

dbo._FSsalestots ON dbo._ItemMaster.F2 = dbo._FSsalestots.IMPN LEFT OUTER JOIN

dbo.[_YTD Sales] ON dbo.OITM.ItemCode = dbo.[_YTD Sales].ItemCode

WHERE dbo.OITM.ItemCode = '%0'

ORDER BY dbo.OITM.ItemCode

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 07:14 PM

    From seeing your Query I believe there are two things you can do.

    1. For the Parameter use square brackets example: ItemCode = '[[%0]]'

    2. Instead of using a fully qualified reference for table names try to use Alias example [[dbo]].[[OITM]] T0

    Suda

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 05:16 PM

    WHERE dbo.OITM.ItemCode = '%0'

    If you mean for the %0 to be your parameter placeholder, it should be in brackets.

    WHERE dbo.OITM.ItemCode = '[%0]'

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.