Please start any new threads on our new site at 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
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  

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?

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-
Go to Top of Page

Premature Yak Congratulator

22864 Posts

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


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.02 seconds. Powered By: Snitz Forums 2000