Link to home
Start Free TrialLog in
Avatar of Ricky White
Ricky WhiteFlag for United States of America

asked on

SQL query or another approach to split rows by data length

I have a sql table in Sql server 2016 with 2 columns CustomerID and Comment.

CustomerID | Comment
1                         Text1
2                         some big text more than 100 ch
3                         Big comment more than 200 characters


What I would like is to get a result set so that the comment does not exceed 10 characters in 1 row if the comment is more than 10 characters, the comment needs to be split in multiple rows of sets of 10 characters. Following is the expected output.

CustomerID | Comment
1                         Text1
2                         some big t
2                         ext more t
2                         han 100 ch
3                         Big comme
3                         nt more th
3                         an 200 cha
3                         racters


Please assist how can this be accomplished using SQL or SSIS.

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ricky White

ASKER

Thank you!