[GIS] Creating a multiversioned view with ArcSDE and SQL Server 2008 R2

enterprise-geodatabasespatial-databasesql serverversioning

I am using the administration command sdetable -o create_mv_view to create a multiversioned view on a table in SQL Server 2008 R2.

Everything appears to be working correctly with one exception: The SDE_get_view_state() scalar function that was included with ArcSDE will only return data for version with name set to 'DEFAULT' and owner set to 'sde'. This is hard-coded in the function.

I have some clients who are using the DBO schema for ArcSDE instead of the SDE schema, and therefore they will not have any version data that meets the criteria.

Does anyone know why the function is checking for the schema owner to be set to 'sde' and more importantly, what is the best way to get this to work for the DEFAULT layer regardless of the owner?

Best Answer

We reported this as a bug in 9.2 a couple of years ago...

Our way around it was to create a multi version view using sdetable, then take the view definition and create a new view in SQL with the calls to SDE_get_view_state() replaced by:

(SELECT state_id FROM sde.sde.SDE_versions WHERE name = 'DEFAULT' AND owner = 'dbo')

It must be replaced at three places in 9.2. (In 8.3 it was 6 occasions). I have not tested this in version 10 yet.

Beware, if you create your own view and change the table definition, your view will not reflect the changes, as it is the sdetable created view that is registred as multiversion view for that particular table.