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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 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
2179 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
22864 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  
 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