March 4, 2004 at 7:19 am
plz anybody suggest how i can pass optional parameter in stored procedure,
can somebody suggest the syntax
Thanks
March 4, 2004 at 7:36 am
BOL covers a topic on optional parameters. Also see my reply on your other thread. That is the example from BOL
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 5, 2004 at 7:01 am
I used coalesce in my stored procedure which has many optional input parameters as follows:
CREATE PROCEDURE sp_Example_Get
@inparm1INT= NULL
,@inparm2CHAR(1)= NULL
,@inparm3VARCHAR(10)= NULL
AS
BEGIN
Set NOCOUNT On
If @inparm1 = ''
Set @inparm1= null
If @inparm2= ''
Set @inparm2= null
If @inparm3= ''
Set @inparm3= null
Begin
Select *
FromEXAMPLE
Wheretabval1= coalesce(@inparm1, tabval1)
Andtabval2
= coalesce(@inparm2, tabval2)
Andtabval3
= coalesce(@inparm3, tabval3)
return 0
end
end
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply