How To: Use SQL to insert a value into a Global ID or GUID column in ArcSDE multiversion views in SQL Server
Instructions provided describe how to insert a value into a Global ID or Globally Unique Identifier (GUID) column in an ArcSDE multiversion view using Structured Query Language (SQL) for SQL Server.
Global ID and GUID data types store registry style strings consisting of 36 characters enclosed in curly brackets. These strings uniquely identify a feature or table row within a geodatabase and across geodatabases. This is how features are tracked in one-way and two-way geodatabase replication and used in relationships or in any application requiring globally unique identifiers.
In a relationship, if a Global ID field is the origin key, a GUID field must be the destination key. Add Global IDs to a feature class in ArcCatalog by right-clicking ArcCatalog and clicking Add Global IDs. The geodatabase maintains these values automatically. Create the GUID field in ArcCatalog, and maintain its values.
When inserting a row into a multiversion view with a Global ID column using SQL, provide a unique GUID value for the Global ID column. As described in the procedure below:
For more information related to Global IDs, GUIDs, and Geodatabase Replication, refer to the ArcGIS Desktop Help installed with ArcGIS Desktop or the link available in Related Information.
Examples provided are specific to SQL Server; steps are similar for other supported databases.
- Assuming that the feature class ‘parcels’ has a global ID field and is registered as versioned:
Open a Windows command prompt and create the multiversion view using the ArcSDE sdetable command:
sdetable -o create_mv_view -T parcels_mv -t parcels -i 5176 -u user1 -p ***** -D <DataBase_Name> -s <Machine_name>
- Open an SQL Server Query Analyzer and login as a user who has permission to edit the 'parcels' feature class.
- Create a new version:
exec sde.create_version N'sde.default', N'parcels_42',2, 2, 'Parcels Version' -- parcels_42 is the name of the version to create and 'Parcels Version' is the description.
- Set the current version for editing:
exec sde.set_current_version 'parcels_42'
- Start the edit session:
exec sde.edit_version 'parcels_42', 1
- Insert a record:
insert into sde.parcels_mv (parcel_id,Globalid) values (87701578, newid())
newid() is a built-in function in SQL server to create new unique GUID.
- Close the edit session:
exec sde.edit_version 'parcels_42', 2
- Use SQL to insert a value into a Global ID or GUID column in ArcSDE multiversion views in Oracle
- ArcGIS Desktop Help