if you must you can use a number table for this. Exampledeclare @TableSvar table ( NewPK int identity(1,1), CustomerID varchar(5) NOT NULL, Vcomments text )Insert Into @TablesVar (CustomerID,vcomments)Select 'A001','The order has been placed for the customer and may recieve in 25 days and deliever at specified address'union allSelect 'A002','The order has been placed for the customer and may recieve in 35 days and deliever to the specified location.'DECLARE @widthSplit INT = 20-- Make a number table. This would be better with a permanent number table....; WITH numbers ([n]) AS ( SELECT ROW_NUMBER() OVER (ORDER BY a.[a]) FROM (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) AS a CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) AS b )SELECT [CustomerID] , ROW_NUMBER() OVER ( ORDER BY s.[CustomerID], n.[n]) AS [NewPK] , SUBSTRING(s.[Vcomments], (n.[n]-1) * @widthSplit, @widthSplit) AS [VComments]FROM @TableSvar AS s CROSS JOIN numbers AS nWHERE n.[n] <= (LEN(CAST(s.[Vcomments] AS VARCHAR(MAX))) / @widthSplit) + 1ORDER BY [CustomerID] , n.[n]
Results:CustomerID NewPK VComments---------- -------------------- -----------------------A001 1 The order has been A001 2 placed for the custoA001 3 mer and may recieve A001 4 in 25 days and delieA001 5 ver at specified addA001 6 ressA002 7 The order has been A002 8 placed for the custoA002 9 mer and may recieve A002 10 in 35 days and delieA002 11 ver to the specifiedA002 12 location.
Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION