DECLARE @FirstName VARCHAR(100)
SET @FirstName = 'King'
DECLARE @LastName VARCHAR(100)
SET @LastName = 'Test'
SELECT FirstName, LastName
FROM Employee
WHERE
FirstName = CASE
WHEN LEN(@FirstName) > 0 THEN @FirstName
ELSE FirstName
END
AND
LastName = CASE
WHEN LEN(@LastName) > 0 THEN @LastName
ELSE LastName
END
GO
SET @FirstName = 'King'
DECLARE @LastName VARCHAR(100)
SET @LastName = 'Test'
SELECT FirstName, LastName
FROM Employee
WHERE
FirstName = CASE
WHEN LEN(@FirstName) > 0 THEN @FirstName
ELSE FirstName
END
AND
LastName = CASE
WHEN LEN(@LastName) > 0 THEN @LastName
ELSE LastName
END
GO
No comments:
Post a Comment