Hi,
I'm trying to write a stored procedure where one of the string parameters passed is 'evaluated' to be used within a query in that procedure.
Giving a simplified example may be clearer.
I have a table which has one of it's fields contain a 'code' from 1 to 99.
I want the sp to return all rows where that code is equal to a string containing all required 'code' values.
so, if I want the query to by run within the sp to be:
select * from mytable where code in ('2','23','34','35','36','37','67','68','69','90','91')
as you can see, it'll be useful to pass this criteria as a string paramater rather than have 100 boolean paramters for each possible value in the list.
However, I can't work out how to evaluate (if that's the right term) a string paramter within a query. Eg:
CREATE PROCEDURE [sp_dmRequest]
@code varchar(255)
AS
SELECTT * from mytable where code in ( EVALUATE(@code) )
Any thoughts on how to achieve this?
Thanks
I'm trying to write a stored procedure where one of the string parameters passed is 'evaluated' to be used within a query in that procedure.
Giving a simplified example may be clearer.
I have a table which has one of it's fields contain a 'code' from 1 to 99.
I want the sp to return all rows where that code is equal to a string containing all required 'code' values.
so, if I want the query to by run within the sp to be:
select * from mytable where code in ('2','23','34','35','36','37','67','68','69','90','91')
as you can see, it'll be useful to pass this criteria as a string paramater rather than have 100 boolean paramters for each possible value in the list.
However, I can't work out how to evaluate (if that's the right term) a string paramter within a query. Eg:
CREATE PROCEDURE [sp_dmRequest]
@code varchar(255)
AS
SELECTT * from mytable where code in ( EVALUATE(@code) )
Any thoughts on how to achieve this?
Thanks