I trying to write a stored procedure where I would like to test a passed in argument for certain value through an IF/Else statement and ultimately INTERSECT the result with another table. Something like the following as a non-working pseudo example.
ALTER PROCEDURE [dbo].[Search]
@Keyword nvarchar(MAX),
@ClasificationId int
AS
BEGIN
SET NOCOUNT ON;
IF (@Keyword != null)
SELECT * FROM Table WHERE [Keyword] LIKE @Keyword
ELSE
SELECT * FROM Table
INTERSECT
IF (@Classification != null)
SELECT * FROM Table WHERE [ClassificationID] = @ClassificationId
ELSE
SELECT * FROM Table
END