dentyne
asked on
Query Help
Greetings:
I wanted to write a stored procedure that had somewhat of a dynamic query. I wanted to pass it a string to be used in the "WHERE" clause. Here is a snippet of code to demonstrate my request:
CREATE PROCEDURE spTesting
@Filter varchar(255)
AS
SELECT *
FROM Table1
WHERE @Filter
So for instance, if @Filter would be "FieldName1 = 'John'"; how would I do this? So once the variable is passed the query would execute like the following:
SELECT *
FROM Table1
WHERE FieldName1 = 'John'
Thanks!
-Jacob
I wanted to write a stored procedure that had somewhat of a dynamic query. I wanted to pass it a string to be used in the "WHERE" clause. Here is a snippet of code to demonstrate my request:
CREATE PROCEDURE spTesting
@Filter varchar(255)
AS
SELECT *
FROM Table1
WHERE @Filter
So for instance, if @Filter would be "FieldName1 = 'John'"; how would I do this? So once the variable is passed the query would execute like the following:
SELECT *
FROM Table1
WHERE FieldName1 = 'John'
Thanks!
-Jacob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER