Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have this problem where I am passing nvarchar parameter to a stored procedure, and the field type in the table for that parameter is int. I am doing that because I am using IN function, and for example if I want to send multiple parameters, that is the only possible way to do through .NET. Or not? The SP doesn't get executed because of the wrong type, and I am trying to cast the value, but I get an error. Here is how I am trying:
Example: @Parameter nvarchar OrderStatusID = ('30, 40')
(o.OrderStatusID IN (CAST(@OrderStatusID as int)) OR @OrderStatusID IS NULL)

Is there a way to cast each value separately, or what will be the best way to cast whole value as int. Thanks in advance for your help
Posted
Updated 7-Nov-10 10:22am
v2

1 solution

Here is a good example how to split the values in SQL. The first method shouldn't even be considered so just skip that. Method 6 would probably be the best example for you.

http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm[^]

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900