November 1, 2003 at 3:14 pm
Have a table with SalesPersons and there approved territories.
ex.
SalesID | States
-------------------
11 VA
12 VANJTX
13 NY
14 OKWAAZPAMS
need to parse the states field into individual states and create a seperate record into new table for each...
SalesID | States
-------------------
11 VA
12 VA
12 NJ
13 NY
13 TX
14 OK
14 WA
14 AZ
14 PA
14 MS
Any help would be greatly appreciated! Thanks.
November 1, 2003 at 5:16 pm
declare @i int
select @i = -1
while @@rowcount > 0
begin
select @i = @i + 2
insert newtbl
select SalesID, substring(States,@i,2)
from oldtbl
where len(Sales) >= @i + 1
end
Cursors never.
DTS - only when needed and never to control.
Cursors never.
DTS - only when needed and never to control.
November 4, 2003 at 5:59 am
Worked like a charm!
Thanks!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply