SQL Server Agent Job with Multi-Versioned View

735
1
07-13-2010 07:17 AM
MeleKoneya
Occasional Contributor III
We have a stored procedure which updates a field in four featureclasses.     The stored procedure is as follows:

--UPDATE SYMBOLOGY FIELD
EXEC sde.set_current_version 'ums_app.MapGuide'
EXEC sde.edit_version  'ums_app.MapGuide', 1

Begin Try
Begin Transaction;

--wtr_hdyrant table



UPDATE ums.wtr_hydrant_mvw
SET symbology = owner + '/' + pm_state
WHERE owner + '/' + pm_state <> symbology

-- Commit Transaction;

--wtr_valve table

-- Begin Transaction;

EXEC sde.set_current_version 'ums_app.MapGuide'
 
UPDATE ums.wtr_valve_mvw
SET symbology = owner + '/' + pm_state 
WHERE owner + '/' + pm_state <> symbology
  
-- Commit Transaction;

--wtr_main table

-- Begin Transaction;

    EXEC sde.set_current_version 'ums_app.MapGuide'

UPDATE ums.wtr_main_mvw
SET symbology = owner + '/' + main_type
WHERE owner + '/' + main_type <> symbology

-- Commit Transaction;

--swr_main table

-- Begin Transaction;

EXEC sde.set_current_version 'ums_app.MapGuide'

UPDATE ums.swr_main_mvw
SET symbology = owner + '/' + main_type
WHERE owner + '/' + main_type <> symbology



------------------------------------
Commit Transaction;

When I try to run the stored procedure as a SQL Server Agent Job,   it does not update the field in the feature classes.

If I run it 'manually' as a stored procedure it does work.      I am dbo.     Has anyone set up a SQL Server Agent Job to run a Stored Procedure?     If so,  do we need to 'run as' a particular user?    I had the owner set to my name, sde, and the data owner name.    Are there any other caveats to using this method?

Thanks for any suggestions,

Mele
0 Kudos
1 Reply
MeleKoneya
Occasional Contributor III
One of DBAs was able to find a solution.

The "SQL Server Agent User" user was given the 'db_owner' role membership and it seems to have resolved our issue with the Stored Procedure.
0 Kudos