-- To split strings as desired fixed length values 
CREATE TABLE #StrTbl (
LongValue varchar( 500 ) NOT NULL DEFAULT (REPLICATE('0123456789' , 50) )
)
INSERT INTO #StrTbl DEFAULT VALUES
INSERT INTO #StrTbl VALUES( REPLICATE( 'abcdefghij' , 50 ) )
SELECT * FROM #StrTbl

-- This will split each column value into 
DECLARE @FixedLen int
SELECT @FixedLen = 50
SELECT n.Number , SUBSTRING( LongValue , ( n.Number * @FixedLen ) + 1 , @FixedLen ) AS FixedLenValue
FROM #StrTbl s JOIN Numbers n 
ON ( LEN( LongValue ) - n.Number * @FixedLen ) > 0 

DROP TABLE #StrTbl
This page was last updated on May 01, 2006 04:28 PM.