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 and nonversioned data used in offline maps. GUIDs can be added to any table.
If the table you want to edit participates in replication or offline mapping 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, you can use the newid() function.
When editing a nonversioned table that is not enabled for archiving, use the function to insert the ID directly to the table. When editing a nonversioned table that is enabled for archiving, use the function to insert the ID to the archive view of the table. When editing a versioned table, use the function to insert a value to the versioned view of the table.
- Log in to SQL Server Management Studio as a user with privileges to edit the table.
If you are editing through a versioned or archive view, the user must also have privileges to edit the view.
- Open a new query window and connect to the database that contains the table or view to be edited.
- Use the newid() function to populate the global ID or GUID column when you insert a record to the table.
INSERT INTO jason.assets (asset_id, globalid) VALUES (57, newid())
Note that you could use the Next_GlobalID stored procedure to get the next ID value. However, you cannot nest a stored procedure in an INSERT statement; therefore, you would have to call the stored procedure to get the next available value, then take the resultant value and include it in your insert statement. This could be useful if you want to see the value before inserting it.