Skip to content

Instantly share code, notes, and snippets.

@thePunderWoman
Created September 25, 2012 21:29
Show Gist options
  • Save thePunderWoman/3784573 to your computer and use it in GitHub Desktop.
Save thePunderWoman/3784573 to your computer and use it in GitHub Desktop.
BaseVehicleID Population
DECLARE @CursorVar1 CURSOR
DECLARE @CurrentVehicle int
DECLARE @CurrentYear int
DECLARE @CurrentMake int
DECLARE @CurrentModel int
SET @CursorVar1 = CURSOR SCROLL DYNAMIC
FOR
select AAIABaseVehicleID, AAIAYearID, AAIAMakeID, AAIAModelID from AAIABaseVehicle
OPEN @CursorVar1
FETCH NEXT FROM @CursorVar1 INTO @CurrentVehicle, @CurrentYear, @CurrentMake, @CurrentModel
WHILE @@FETCH_STATUS = 0
BEGIN
Update Application set BaseVehicleID = @CurrentVehicle
WHERE FromYear = @CurrentYear AND AAIAMakeID = @CurrentMake AND AAIAModelID = @CurrentModel
FETCH NEXT FROM @CursorVar1 INTO @CurrentVehicle, @CurrentYear, @CurrentMake, @CurrentModel
END
CLOSE @CursorVar1
DEALLOCATE @CursorVar1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment