Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedures and single row Loops

Status
Not open for further replies.

Liam1

Programmer
Nov 7, 2002
43
GB
Hello,

I have a text field:

@(999104,1)

and I want to pick out
'999104' and then '1'
Easy!

But what heppens if:

@(999104,1) + @(999105,2)
and I want to obtain
'999104' & '1' and then '999105' '2'

I have a cursor that is set up to bring in the rows from a table, and will try to find a loop for each row, but how do I do this for field data?

How do I loop along a text field, to keep using INDEX to pull out the various strings.

How can I test that I have actually reached the end of the cell?

Thanks in Advance,

Liam1
 
You'll have to use a local variable and assign the string to it:
-> extract the parts
-> assign the rest of that string to the variable
and loop (using repeat/while/loop) until the variable is empty.

But what are you actually trying to achieve?
How many rows are processed by your cursor?
Is the input data always in the same format, @(xxxxxx,y) repeated several times?
Is @(xxxxxx,y) always the same length?
What's the maximum length of your input data?
Could you post some examples of your real input data?

You can probably replace that cursor with a single plain SQL statement to split the input data, this will be probably a magnitude faster.

Dieter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top