Created
December 23, 2022 10:51
-
-
Save hendrasyp/54614ff2bac2331548c0f2ebb56c9334 to your computer and use it in GitHub Desktop.
SQL Server - Stored Procedure Show Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [Schema].[SP_Name] (@Param [DataType(Size)] = DEFAULT_VALUE) | |
AS | |
BEGIN | |
-- Condition With Coalesce | |
WHERE COALESCE(id, NULL) = COALESCE(@paramId, id, NULL) -- EQUALS | |
AND COALESCE(name, '%') LIKE COALESCE('%' + @paramName + '%', name, '%') -- LIKE | |
AND ( -- DATE RANGE | |
CONVERT(VARCHAR(10) , date, 111) >= CONVERT(VARCHAR(10) , @FromDate, 111) AND | |
CONVERT(VARCHAR(10) , date, 111) <= CONVERT(VARCHAR(10) , @ToDate, 111) | |
); | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment