Named Parameters for User Defined Functions without EXEC
Currently, stored procedures and scalar user-defined functions invoked with the EXEC keyword support named parameters.
User-defined functions invoked as part of a SELECT or other statement require ordered parameter specification without parameter names.
Specifying parameter names should be supported when invoked as part of a SELECT statement.
When any parameters are named, all must be named,
When any parameters are named, any omitted parameters should receive default values. Omitted parameters without default values should result in an error.
Upvotes: 25<=-=Feb 7 2017 7:34PM=-=>
Yes! I myself a use heavily inline table value functions and that would improve the clarity of their use even more!<=-=Mar 5 2017 2:48PM=-=>
We understand the requirement, and it is good that it gets a lot of votes in very short period. It is in out backlog and we will consider it for some of the next releases; however, currently we cannot confirm when it will be implemented..<=-=Dec 22 2017 3:17PM=-=>
This would be quite incredibly useful. When it was added to C#, it was a “so-what?” thing for me at the time – but now, I don’t know how I ever coded without named parameters. It has saved me countless hours getting things right the first time, and not chasing around dumb problems. I am sure the same would be true if SQL Server supported named parameters in User-Defined Functions. My vote is not just a yes, but a hell yes!
Tomasz Jagusz commented
I agree with @Steven. default keyword shouldn't be required.
Named parameters would be awesome, but top priority should be removing of that default keyword - it isn't needed when You call a function with execute so why do You need it when You use function is select?
Steven Hibble commented
I mostly want the ability to omit parameters with default values. Named parameters would be awesome, too.
Alejandro Chavarria commented
This should absolutely be a feature in SQL Server. I depend on functions heavily and having the ability to sometime update the underlying function without having to go through all of the code would be a huge win. Not to mention all of the other comments pointing out the ability to avoid really stupid mistakes encountered when using ordered parameters.