September 12, 2008 at 9:13 am
I have a S.P. written like this
create proc my_sp
@p1 varchar (20) = 'Default',
@p2 varchar (20),
@p3 varchar (20)
as
--some code goes here...
go
My question is how do I execute this proc so the default value in parameter 1 (@p1) is used?
September 12, 2008 at 9:41 am
Don't call the parameter when you exec the SP
exec my_sp
@p2 = [some value]
, @p3 = [some value]
go
_____________________________________________________________________
- Nate
September 15, 2008 at 6:47 am
Thanks RP
September 15, 2008 at 6:50 am
You could also use the DEFAULT reserved word in SQL this will force it to use the default value as well
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 16, 2008 at 12:09 pm
I generally (ok -- always) put parameters with default values at the end of the list:
create proc my_sp
@p1 varchar (20),
@p2 varchar (20),
@p3 varchar (20) = 'Default'
as
--some code goes here...
go
That way I don't have to use parameter naming or the "default" keyword:
exec my_sp @p1, @p2, @p3; -- provide a value
exec my_sp @p1, @p2; -- use default for @p3It constantly irks me that this method is not allowed in functions.
Tomm Carr
--
Version Normal Form -- http://groups.google.com/group/vrdbms
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply