mysql 字串轉多列資料
阿新 • • 發佈:2019-02-09
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO
CREATE FUNCTION [dbo].[zoe_split]
(
@c VARCHAR(8000) ,
@split VARCHAR(2)
)
RETURNS @t TABLE ( col VARCHAR(MAX) )
AS
BEGIN
WHILE ( CHARINDEX(@split, @c) <> 0 )
BEGIN
INSERT @t
( col
)
VALUES ( SUBSTRING(@c, 1, CHARINDEX(@split, @c) - 1)
)
SET @c = STUFF(@c, 1, CHARINDEX(@split, @c), '')
END
INSERT @t
( col )
VALUES ( @c )
RETURN
END
GO