'String_Split example not working for me, says insufficient parameters

Using SQL Server 2016 and latest SSMS, I'm trying to take a csv string and split it and then insert into table-value parameter variable and I'm getting error squiggles under the string_split function.

Is what I'm doing even possible?

DECLARE @tvParam TABLE (FirstName nvarchar(50))

DECLARE @s VARCHAR(MAX) = '0152,1731'

INSERT INTO @tvParam 
    SELECT Value 
    FROM STRING_SPLIT(@s, ',')

enter image description here



Solution 1:[1]

Not sure what build of SSMS you're using but that is just IntelliSense being not so intelligent. In anticipation of these changes to that function, IntelliSense was updated to expect 3 parameters unconditionally. It doesn't understand (a) that the 3rd parameter is optional, and (b) where it's even supported. Current/future builds of SSMS should get better at this over time.

Here is SSMS 18.11.1:

enter image description here

Thankfully, you can ignore the message, which is just a parse-time warning. The code runs successfully.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1