parsing huge string into stored procedure

  • What is a good way to parse a string of data coming in from an outside source...?

    lets say the string will be 25,000 characters

    ie:: (bad way)

    alter

    proc [dbo].[set__]

    @input0 varchar

    (8000),

    @input1 varchar

    (8000),

    @input2 varchar

    (8000),

    @input3 varchar

    (8000),

    @input4 varchar

    (8000),

    @input5 varchar

    (8000)

    as

    declare @input varchar(8000)

    declare @inputC int

    set

    @inputC=-1

    nextinput

    :

    set @inputC=@inputC+1

    if(@inputC=0)set @input=@input0

    else if(@inputC=1)set @input=@input1

    else if(@inputC=2)set @input=@input2

    else if(@inputC=3)set @input=@input3

    else if(@inputC=4)set @input=@input4

    else if(@inputC=5)set @input=@input5

    else

       return

    --do stuff here..

    goto nextinput

  • Wouldn't VARCHAR(MAX) do the trick?

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • thanks,

    I looked it up, and max is only for 2005 (I'm using 2000).

    I can use text type instead.

    Would it be better to execute the input from a file or via the string?

  • OK, this is the 2005 forum, that's why I thought you had it.

     

    As far as the file or string question....I don't know, but I'm someone else will answer that one...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • It depends... what kind of string is it??? CSV, Fixed Field, XML, Quoted CSV, or ????

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

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