- SET ANSI_NULLS ON
- GO
-
- SET QUOTED_IDENTIFIER ON
- GO
-
- -- =============================================
- -- Author: Insus.NET
- -- Create date: 2019-05-09
- -- Update date: 2019-05-09
- -- Description: 拆分字符串转为表
- -- =============================================
-
- CREATE FUNCTION [dbo].[tvf_SplitStringToTable]
- (
- @InputString NVARCHAR(MAX)
- )
- RETURNS @dump TABLE
- (
- [Char] [nvarchar](2) NULL
- )
- AS
- BEGIN
- DECLARE @position INT = 1, @strLen INT = LEN(@InputString)
- WHILE @position <= @strLen
- BEGIN
- INSERT INTO @dump VALUES(SUBSTRING(@InputString, @position, 1))
- SET @position = @position + 1
- END
- RETURN
- END
- GO