tpcolson

Real-time Geodatabase Replication? Part 6

Blog Post created by tpcolson Champion on Jan 24, 2015

In Real-time Geodatabase Replication? Part 1 you were introduced to SQL Real-Time Replication. One requirement of SQL Merge Replication is that the table being replicated must have a rowguidcol. This is easy with a cursor:

 

DECLARE 
@sql VARCHAR(500), 
@tableName VARCHAR(128)
DECLARE gandgCursor CURSOR 
FOR 
SELECT 
table_name
FROM 
SDE_column_registry
WHERE 
table_name like 'CR%' 
ORDER BY 
table_name ASC 
OPEN gandgCursor 
FETCH NEXT FROM gandgCursor  
INTO @tableName 
WHILE ( @@FETCH_STATUS = 0 ) 
BEGIN 
SET @sql = ' 
ALTER TABLE [dbo].['+ @tableName + '] 
ALTER COLUMN GlobalID ADD ROWGUIDCOL ;
' 
 PRINT 'Executing Statement - '+ @sql 
 EXECUTE ( @sql ) 
 FETCH NEXT FROM gandgCursor  
 INTO  @tableName 
 END 
 CLOSE gandgCursor 
 DEALLOCATE gandgCursor

Outcomes