语法:
STRING_SPLIT(string , separator)
参数说明:
string: 任何字符类型(例如 nvarchar、varchar、nchar 或 char)的表达式 separator: 任何字符类型(例如 nvarchar(1)、varchar(1)、nchar(1) 或 char(1))的单字符表达式,用作串联子字符串的分隔符
根据 字符 把 字符串 拆分为集合
SELECT * FROM STRING_SPLIT('a,b,d,c',',')
结果
根据 字符 把 集合中的字符串 拆分为多行数据
WITH V_ALL AS ( SELECT '01' AS [Key], 'Value_01,Value_02,Value_03' as Test UNION ALL SELECT '02' AS [Key], 'Value_02' as Test UNION ALL SELECT '03' AS [Key], 'Value_02,Value_03' as Test ) SELECT [Key], Test, Value FROM V_ALL CROSS APPLY STRING_SPLIT(Test, ',')
结果
标签:02,STRING,Value,SPLIT,Test,MSSQL,SELECT From: https://www.cnblogs.com/CRobot/p/17566301.html