Inserting a value into a global ID or GUID column in SQL Server using SQL
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. Global IDs are used to maintain uniqueness of records in one-way and two-way geodatabase replicas. GUIDs can be added to any layer.
Therefore, if the table you want to edit participates in replication or contains a GUID, you must insert a unique value to the global ID or GUID column when you insert a new record to the table using SQL. To do this, use the Microsoft SQL Server function newid(). If the table you are editing is versioned, use the newid() function to edit a multiversioned view of the table with SQL.
You can add global IDs to a feature class in the Catalog window by right-clicking the dataset and clicking Add Global IDs. The geodatabase maintains these values automatically when editing through ArcGIS.
- If you are editing a versioned table, create a multiversioned view of it as described in Creating multiversioned views.
- Log in to SQL Server Management Studio as a user with permissions to edit the table.
- Open a new query window and connect to the database that contains the view to be edited.
- If you are editing a versioned table, create a new version, set the version, then start an edit session as described in Editing versioned data in SQL Server using multiversioned views and SQL. If you are editing a nonversioned table, proceed to the next step.
-
Use the newid() function to populate the global ID or GUID column when you insert a record to the table.
INSERT INTO jason.asset_mv (asset_id,globalid) VALUES (57,newid())
- Close the edit session when you finish editing if you are editing through a multiversioned view. See Editing versioned data in SQL Server using multiversioned views and SQL for syntax information.