re-define an incoming string of data into columns

  • I have a string of data (2207 characters in this case) that's coming into a stored procedure from a mainframe system. I'd like to lay these characters into a pre-defined format so I can break the data into the data fields that match the mainframe layout.

    I know I can do SUBSTRING(...) type logic to split the string out, but I am hoping there is a better/cleaner way to do this. I've not done much with user-defined data types and such. Didn't know if anything like that would do what I want.

    Thanks for any advice.

  • what does the string look like? are there nice delimiters or is it a fixed width set up?

    with delimiters have a look at Jeff Moden's DelimitedSplit8K[/url]. if its fixed width SUBSTRING may be the best way to go but with out seeing the exact requirements we cant be sure.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

  • Not only SUBSTRING other things are also there like CHARINDEX,PATINDEX,LEFT,RIGHT,TRIM etc by which you can format the string.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply