Path: csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Anton Shepelev Newsgroups: comp.databases.ms-sqlserver Subject: Parameters with default values in functions Date: Fri, 1 Mar 2024 13:53:10 +0300 Organization: A noiseless patient Spider Lines: 36 Message-ID: <20240301135310.27742ad2db04a98c37f5099e@g{oogle}mail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: dont-email.me; posting-host="eeceec7014f61528356a85bf77e35708"; logging-data="1268270"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qnhxKkCpmICEeS7XbcGsOREwnqcgnNp0=" Cancel-Lock: sha1:Jy9TnCq5VYVq14TDKq1NFKebvss= X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Xref: csiph.com comp.databases.ms-sqlserver:2236 Hello, all 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. The documentation says it should work: -- Transact-SQL Inline Table-Valued Function Syntax CREATE [ OR ALTER ] FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ] [ type_schema_name. ] parameter_data_type [ NULL ] [ = default ] [ READONLY ] } [ ,...n ] ] ) The value of each declared parameter must be supplied by the user when the function is executed, unless a default for the parameter is defined. What am I doing wrong on my MSSQL v. 13? -- () ascii ribbon campaign -- against html e-mail /\ www.asciiribbon.org -- against proprietary attachments