SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Optional parameter for function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Passero
Starting Member

12 Posts

Posted - 01/24/2008 :  04:44:01  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
2062 Posts

Posted - 01/24/2008 :  06:32:31  Show Profile  Visit jackv's Homepage  Reply with Quote
Try using "=''"

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

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 01/24/2008 :  09:18:24  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
select @something = someFunction('abc',default);

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000