The title rang for half a day or felt lied.
Actually, there's this piece of data.
To become more than one.
Code:
; withRoy as (SELECT [Datarowstartindex] , [Datarowendindex] , [Datacolumnstartindex] , [Datacolumnendindex] , [Separator], [SheetName]=CAST( Left([SheetName],CHARINDEX(',',[SheetName]+',')-1) as nvarchar( -)), Split=CAST(STUFF([SheetName]+',',1,CHARINDEX(',',[SheetName]+','),"') as NVARCHAR( -)) fromAccesstypeforexcel UNION All SELECT [Datarowstartindex] , [Datarowendindex] , [Datacolumnstartindex] , [Datacolumnendindex] , [Separator], [SheetName]=CAST( Left(Split,CHARINDEX(',', Split)-1) as NVARCHAR( -)), Split= CAST(STUFF(Split,1,CHARINDEX(',', Split),"') as NVARCHAR( -)) fromRoyWHERESplit>"')SELECT [Datarowstartindex] , [Datarowendindex] , [Datacolumnstartindex] , [Datacolumnendindex] , [Separator], [SheetName] fromRoyOPTION(maxrecursion0)
This is to divide the string by ",",
Each time the first comma ([SheetName]) and the following part (split) are divided,
And then self-union,
Take the last remaining section (split) to continue repeating the previous split operation,
Until the split> ' condition is not met, a piece of data is split.
SQL Server uses a CTE to implement a column separated by characters into multiple lines