Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #2237

Re: Parameters with default values in functions

Path csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Parameters with default values in functions
Date Fri, 01 Mar 2024 23:18:17 +0100
Organization Erland Sommarskog
Lines 28
Message-ID <XnsB128ED1216A95Yazorman@127.0.0.1> (permalink)
References <20240301135310.27742ad2db04a98c37f5099e@g{oogle}mail.com>
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Injection-Info dont-email.me; posting-host="dda5fad68a1602f8f996bc03ef0bb6d3"; logging-data="1553819"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181eCeYTVzeMjcOUeYPFg5/"
User-Agent Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32)
Cancel-Lock sha1:CkmiPVPGUObX6Vzi96M/P7//crc=
Xref csiph.com comp.databases.ms-sqlserver:2237

Show key headers only | View raw


Anton Shepelev (anton.txt@g{oogle}mail.com) writes:
> MSSQL allows default values in parameters to functions:
> 
>   CREATE FUNCTION test( @v INT = 1 )
>   RETURNS TABLE AS
>   RETURN  ( SELECT @v AS v )
> 
> but will not let me use them -- the invocation
> 
>   SELECT * FROM test()
> 
> fails with:
> 
>   An insufficient number of arguments were supplied for the
>   procedure or function test.
> 

I'm about to say that I don't even want to talk about this, because
it is so stupid. That is, you must supply the DEFAULT keyword explicitly:

SELECT * FROM dbo.test(DEFAULT)

Which of course defies quite much of the idea with a default parameter 
when you want to add a new parameter to an existing function.

Here is a feedback item you can vote for:
https://feedback.azure.com/d365community/idea/95dbf609-5a25-ec11-b6e6-
000d3a4f0da0

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Parameters with default values in functions Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-03-01 13:53 +0300
  Re: Parameters with default values in functions Erland Sommarskog <esquel@sommarskog.se> - 2024-03-01 23:18 +0100
    Re: Parameters with default values in functions Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-03-05 11:36 +0300
      Re: Parameters with default values in functions Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-03-05 11:39 +0300

csiph-web