sql loop help
Posted on 2011-03-16
I have a variable that has an address. State and zip have been pulled out and the state is stored in a variable called @state
@address may have this in it 5220 Main St Winston Salem..
I have a function that gets the word in a string.. Its called udf.getword and it just needs @address and a number that tells me what word you want to pull out from the left.. so
select udf.getword (@address,1) gives me Salem.. and (@address,2) gives me Winston..etc..
How do get below using my udf?
I want to loop 4 times to get the below results populated in a variable called @lastSearchValue.
First loop gives me Main St Winston Salem
Second loop gives me St Winston Salem
Third loop gives me Winston Salem
Fourth loop gives me Salem