Share via

String Split not working - not enough arguments

Christopher Jack 1,616 Reputation points
2022-03-04T13:37:28.853+00:00

Hi,

I am trying to insert a string results into a temp table using the following

create table #Temp
(
sku nvarchar(400)
)
insert #Temp(sku)
SELECT value
from STRING_SPLIT (@sku2, ',')

However I am getting the following error when I highlight string_split - an insufficient nummber of arguments where supplied for for the function String_split .

Thanks

Chris

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Tom Phillips 17,786 Reputation points
2022-03-04T13:55:30.827+00:00

That is just a warning from Intelisense in SSMS. It can be ignored. I hope it gets fixed soon.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Tom Phillips 17,786 Reputation points
    2022-03-04T19:53:05.72+00:00

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments

  2. Olaf Helper 47,621 Reputation points
    2022-03-04T13:55:08.163+00:00

    following error when I highlight

    Syntax highlighting in SSMS don't work that well.
    And I guess you use an older SSMS version, which don't know correct syntax of the function.

    Ignore it or install latest SSMS version.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  3. LiHong-MSFT 10,061 Reputation points
    2022-03-07T08:14:28.777+00:00

    Hi @Christopher Jack

    String Split not working

    You mean the code that you post doesn't work at all, or the code can work, but with a red squiggly line for syntax error.

    If it is the first case,
    First check if the SQLsever version is SQL Server 2016 (13.x) and later.
    And then check if Compatibility level 130 plus.Because STRING_SPLIT requires the compatibility level to be at least 130. When the level is less than 130, SQL Server is unable to find the STRING_SPLIT function.
    To change the compatibility level of a database, refer to View or Change the Compatibility Level of a Database.
    Last, make sure @sku2 is an expression of any character type (for example, nvarchar, varchar, nchar, or char)
    If it is the second case,
    You can choose to ignore it, like other experts said. Or update the version of SSMS.

    Best regards,
    LiHong

    Was this answer helpful?

    0 comments No comments

  4. Yitzhak Khabinsky 27,196 Reputation points
    2022-03-04T13:52:03.583+00:00

    Hi @Christopher Jack ,

    Azure SQL Server introduced a third optional parameter to the string-split-transact-sql function:

    STRING_SPLIT ( string , separator [ , enable_ordinal ] )

    SQL Server on prem. doesn't support it yet that 3rd parameter. Just SQL Server 2022 will have it.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.