LoginSignup
0
0

More than 5 years have passed since last update.

引数が省略されたら全件抽出するストアド

Posted at

ISNULLを使うと簡単にできました。

example.sql
CREATE PROCEDURE
    [dbo].[Example]
        @Param1 nchar(3) = NULL, 
        @Param2 nchar(5) = NULL
AS

BEGIN
    SELECT
        *
    FROM
        TABLENAME
    WHERE
        column1= isnull(@Param1 , column1)
        AND column2= isnull(@Param2 , column2)
END
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0