Accessing SQL variables within"WITH" statement

Hi
I'm trying to add an input variable (part_number) to my SQL Stored Proc but it seems to ignore the value I pass into the Stored Proc.

The only odd thing with the Stored Proc is that it uses the "WITH" convention to optimise it, and I'm wondering if you have to access a variable differently when used within the "WITH" convention? thanks
Fergal
fjkilkenAsked:
Who is Participating?
 
Anthony PerkinsConnect With a Mentor Commented:
Yes.  There are a number of ways (from good to bad):
1. Table-Valued parameters.
2. Xml
3. Delimted string.
4. Dynamic SQL.
0
 
ste5anSenior DeveloperCommented:
No,  but are you using this parameter in your sproc?
0
 
fjkilkenAuthor Commented:
Yes, it's being refernced in the proc, I'm trying to pass a "part_number" value into the proc
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
ste5anSenior DeveloperCommented:
Well, then you should post your procedure and it's invokation. Cause my Crystal Ball (tm) is not working right now..Crystal Ball (tm)
0
 
fjkilkenAuthor Commented:
ha ha - good point, I'm just trying to trim-down the query now to the pertinent code, but the issue is that now the parameter IS being recognised, so I'm trying to determine from the removed code as to what could be causing the parameter to be blocked.
0
 
Anthony PerkinsCommented:
You do realize we have no idea what you are talking about, right?  

If you want help, try posting your query and explain what you are trying to achieve.
0
 
fjkilkenAuthor Commented:
Thanks for the comments - after cleaning-up my query in prep. for posting it here, my variable is now functioning as expected, I'm not sure exactly what fixed it but it's now working.
In relation to this however, I need to be able to pass-in multiple values as in a SQL "IN" query, for example;
instead of simply using a single value-

WHERE @StockNumber = 'ABC'

I'd like to be able to do:

WHERE @StockNumber IN ('ABC','123','XYZ')

- is this possible?
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.