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)
 Optional parameter for function

Author  Topic 

Passero
Starting Member

12 Posts

Posted - 2008-01-24 : 04:44:01
I have created a function:

create function someFunction
(@val varchar(200),@key int = 1)
...

When i execute the function:
@something = someFunction('abc',2)
it works but
@something = someFunction('abc');

I have to pass the other parameter. Is it possible to not pass it? I can enter DEFAULT but i do not want to pass it at all, is it possible? How do i define my function?

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-01-24 : 06:32:31
Try using "=''"

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-24 : 09:18:24
select @something = someFunction('abc',default);

Madhivanan

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

- Advertisement -