1. 程式人生 > >mysql 字串轉多列資料

mysql 字串轉多列資料

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