I need help with dynamic stored procedure.
This code will work:
CREATE PROCEDURE usp_employees @in_cookieid int
AS
DECLARE @searchcriteria varchar(50)
if @searchcriteria = NULL
SELECT *
FROM employees
where (employeeid = @in_cookieid)
else
SELECT *
FROM employees
where (employeeid = @in_cookieid)
AND empname LIKE '@searchcriteria'
But is there a way to shorten it so I don't have to rewrite all the
different variations?
Something like this?
CREATE PROCEDURE usp_employees @in_cookieid int
AS
DECLARE @searchcriteria varchar(50)
SELECT *
FROM employees
where (employeeid = @in_cookieid)
IF @searchcriteria = NULL
AND empname LIKE '@searchcriteria'
Thanks,
John
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]