Monday, 15 February 2010

sql - How can I pass and use array in a stored procedure? -


In my stored procedure, I must select based on user input

The query will be like this

  SELECT A, virtual from B, where B = array [0] or B = array [1] or B = array [2]   

objects in the number array I do not know the number of elements in the user selection array will determine.

How can I get it? If I can do this, I can use the same process for each element in the array.

Instead you can create a

  type TB Dbo.type_name AS table (column 1 INT not to null)   

From the single columned code to the data field as the parameter from the page (values ​​are the same as that array).

In the process, you can use it as follows

  CREATE PROCEDURE proc_name @ ARRA dbo.type_name READONLY In the selection as A, B In invention B in (@ Select column 1 from the arrow)    

No comments:

Post a Comment