Fix “An insufficient number of arguments were supplied for the procedure or function GENERATE_SERIES” in SQL Server

If you’re getting error 313 with a message that reads “An insufficient number of arguments were supplied for the procedure or function GENERATE_SERIES” in SQL Server, it’s because you’re not passing enough arguments to the GENERATE_SERIES() function.

The GENERATE_SERIES() function/relational operator accepts a minimum of two arguments, and a maximum of three (at least, this is the case at the time of writing). Passing less than two arguments will result in the above error.

To fix this error, be sure to provide at least two arguments when using the GENERATE_SERIES() function.

Example of Error

Here’s an example of code that produces the error:

SELECT * FROM GENERATE_SERIES( 1 );

Result

Msg 313, Level 16, State 3, Server e869805b9fd8, Line 1
An insufficient number of arguments were supplied for the procedure or function GENERATE_SERIES.

As the error message states, I didn’t pass enough arguments to the GENERATE_SERIES() function.

Solution

To fix this issue, I need to add at least one more argument:

SELECT * FROM GENERATE_SERIES( 1, 3 );

Result

value      
-----------
          1
          2
          3

The first argument specifies the start point, the second specifies the end point.

We have the option of passing a the third argument to specify the step amount (i.e. the amount that the series will increment by).

Example:

SELECT * FROM GENERATE_SERIES( 10, 45, 15 );

Result

value      
-----------
         10
         25
         40