根据指定字符分割字符串并输出表格
程序员文章站
2023-12-28 14:16:28
...
根据指定字符分割字符串并输出表格 无 CREATE FUNCTION [dbo].[Splitstring] (@StringToSplit NVARCHAR(max), @CharSpliter NVARCHAR(5)) returns @SplitTable TABLE ( data NVARCHAR(50)) AS BEGIN DECLARE @Count INT SET @Count = 1 WHILE ( Charindex(@Ch
根据指定字符分割字符串并输出表格CREATE FUNCTION [dbo].[Splitstring] (@StringToSplit NVARCHAR(max), @CharSpliter NVARCHAR(5)) returns @SplitTable TABLE ( data NVARCHAR(50)) AS BEGIN DECLARE @Count INT SET @Count = 1 WHILE ( Charindex(@CharSpliter, @StringToSplit) > 0 ) BEGIN INSERT INTO @SplitTable (data) SELECT Data = Ltrim(Rtrim(Substring(@StringToSplit, 1, Charindex(@CharSpliter, @StringToSplit) - 1) )) SET @StringToSplit= Substring(@StringToSplit, Charindex(@CharSpliter, @StringToSplit ) + 1, Len(@StringToSplit)) SET @Count = @Count + 1 END INSERT INTO @SplitTable (data) SELECT Data = Ltrim(Rtrim(@StringToSplit)) RETURN END go