Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Passing parameters

Author  Topic 

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-03-24 : 07:21:42
Hi everyone,
can any body tell me
What is the difference between the following


CREATE proc test
@Id as int,
@value as varchar(10) = NULL,
@outStatus as bit OUTPUT
AS

SELECT @id, @value, @outstatus

CREATE proc test1
@Id as int,
@value as varchar(10),
@outStatus as bit OUTPUT
AS

SELECT @id, @value, @outstatus


Vaibhav T

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-03-24 : 07:26:58
the 2nd parameter @value in Stored Procedure test has a default value of NULL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-03-24 : 08:07:57
That means
passing the argument @value in sp test is optional
is it like that ?

Vaibhav T
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-24 : 11:47:55
quote:
Originally posted by vaibhavktiwari83

That means
passing the argument @value in sp test is optional
is it like that ?

Vaibhav T


exactly. if you omit passing a value for that it will run with default value which is NULL

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-25 : 03:32:38
And in order to force the variable to have default value, you should execute the procedure by

EXEC test1 @id=some_value,@outStatus =some_value


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-03-25 : 03:56:14
Okey thanks to all.

Vaibhav T
Go to Top of Page
   

- Advertisement -