Note that there are some explanatory texts on larger screens.

plurals
  1. POTRANSACT SQL error 216
    primarykey
    data
    text
    <p>I have a Transact SQL script that creates a table AND a table value function based on that table which I invoke from another script using SQLCMD mode; for example:</p> <p>:r .\MyTableScript.sql</p> <p>All is working well, both at DB generation time and at execution time. Now I split the script into two files to separate the function, I end up with something like this in the 'master script':</p> <p>:r .\MyTableScript.sql</p> <p>:r .\MyTableFunctionScript.sql</p> <p>All works well to generate the database, however when I call the function I get error "216 Parameters were not supplied for the function".</p> <p>This is weird.</p> <p>If I call the function with the wrong number of parameters I get the correct message, something like '... invalid number or arguments ...'; if I call the function with arguments of the wrong type then again I get the appropriate message about the wrong type for the arguments.</p> <p>But when I call the function with the right arguments I get the aforementioned message.</p> <p>I know that CREATE FUNCTION must be the first statement in a batch and it is. I also tried with and without semicolon's in the 'right' places.</p> <p>Now, I put back the function into the same script file as the table itself (just after the DDL for the table) and regenerate the database and all is now working fine again.</p> <p>I can leave it like this (the table and the function in one big script file), BUT I would prefer to spilt the table and the function scripts into two SQL scripts files.</p> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload