SQL Server 2016 引入了一个新的内置表值函数STRING_SPLIT,它将指定的分隔字符拆分提供的输入字符串,并以 table 的形式返回输出分隔值,每个分隔符之间的每个分隔值都有一行。 STRING_SPLIT 函数有两个参数: STRING_SPLIT(字符串,分隔符) 该字符串是具有 char,nchar,varchar 或 nvarchar 数据类型的字符表达式。分隔...
检查数据库兼容性级别:如果你的数据库兼容性级别设置为低于130(SQL Server 2016),那么String_Split函数可能无法正常工作。你可以通过以下命令来检查和更改数据库兼容性级别: 检查数据库兼容性级别:如果你的数据库兼容性级别设置为低于130(SQL Server 2016),那么String_Split函数可能无法正常工作。你可以通过以下命令来检...
CREATE FUNCTION dbo.Split ( @String varchar(8000), @Delimiter char(1) ) returns @temptable TABLE (items varchar(8000)) as begin declare @idx int declare @slice varchar(8000) select @idx = 1 if len(@String)<1 or @String is null return while @idx!= 0 begin set @idx =charindex(@Del...
Transact-SQL reference for the STRING_SPLIT function. This table-valued function splits a string into substrings based on a character delimiter.
You've tagged this SQL Server 2008 but future visitors to this question (using SQL Server 2016+) will likely want to know about STRING_SPLIT. With this new builtin function you can now just use SELECT TRY_CAST(value AS INT) FROM STRING_SPLIT ('1,2,3,4,5,6,7,8,9,10,11,12,13...
I wrote a Table Valued Function in Microsoft SQL Server 2008 to take a comma delimited column in a database to spit out separate rows for each value. Ex: "one,two,three,four" would return a new table with only one column containing the following values: one two three four Does...
SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric STRING_SPLITis a table-valued function that splits a string into rows of substrings, based on a specified separator char...
split in mssql server declare @s nvarchar(max) select @s = N',,45 , 1, 56, 346 456,8,5, ,d,1,4, 5 9 ,t,,4,5 ,,, w, 3,,' select * from dbo.split(@s,1,0) CREATE FUNCTION SPLIT ( @s nvarchar(max), @trimPieces bit,...
SQL Server 2016 (13.x) 和更新版本 Azure SQL 資料庫 Azure SQL 受控執行個體 Azure Synapse Analytics Microsoft Fabric 中的 SQL 分析端點 Microsoft Fabric 中的倉儲 STRING_SPLIT是數據表值函式,會根據指定的分隔符,將字串分割成子字串的數據列。
SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric STRING_SPLITis a table-valued function that splits a string into rows of substrings, based on a specified separator char...