webressurs
asked on
Dynamic "where" statement (Stored procedure)
Se attached code snippet. I need help to make the "whereStatement" correct.
If @guid is NOT blank I want the where statement to be like this:
where active='1' and guid=@guid
If @guid is blank I want the where statement to be like this:
where active='1' and codeID=@codeID
Thanks for all help :)
If @guid is NOT blank I want the where statement to be like this:
where active='1' and guid=@guid
If @guid is blank I want the where statement to be like this:
where active='1' and codeID=@codeID
Thanks for all help :)
ALTER PROCEDURE [dbo].[spKodeDetaljPay]
(
@codeid smallint,
@guid varchar(64)
)
AS
BEGIN
Select title, text,
(Select name from tblPersonPay where tblCode.PersonID = tblPersonPay.PersonID) as Name,
(Select email from tblPersonPay where tblCode.PersonID = tblPersonPay.PersonID) as email from tblCode
where active='1' -- and " & whereStatement
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.