Thursday, 27 July 2017

STRING_SPLIT function in Sql Server 2016

STRING_SPLIT function in Sql Server 2016

Sql Server 2016 is introduced STRING_SPLIT is one of the new built-in table valued function. 
This function splits the input string by the specified character separator and returns output as a table.

SYNTAX: -  STRING_SPLIT ( input_string, separator)
Where input_string can be type of CHAR, VARCHAR, NVARCHAR and NCHAR. 
Separator is a single character can be one of the type CHAR(1), VARCHAR(1), NVARCHAR(1) and NCHAR(1).

Example 1: Simple STRING_SPLIT function example 



Example 2: passing string and separator parameters as variables 

DECLARE @Input_String VARCHAR(MAX) = ',,',
        @separator CHAR(1) =','

SELECT * FROM STRING_SPLIT(@Input_String, @separator)


No comments:

Post a Comment

Note: only a member of this blog may post a comment.