//Preventing duplicate RecId - Copying version control from Source to Target (Version Control Data) - BCP
//Destination DB
SELECT MIN(RecId) AS DestMinRecId FROM SysVersionControlMorphXRevisionTable
//Source DB
SELECT MAX(RecId) AS SourceMaxRecId From SysVersionControlMorphXRevisionTable
valueToAdd = (maxSourceRecId – minTargetRecId) + 1
//Update SQL Query in Destination DB
UPDATE SysVersionControlMorphXRevisionTable
SET RecId = RecId + valueToAdd
UPDATE SystemSequences
SET NEXTVAL = (SELECT MAX(RecId) + 1 FROM SYSVERSIONCONTROLMORPHXREVISIONTABLE) WHERE tabid = 2543
//BCP - bulk Copy Data
//BCP syntax : bcp <table_name> <direction> <file_name> <options>
options
[-n native type] [-c character type] [-S server name] [-U username]
[-P password] [-T trusted connection]
bcp dbo.testdb.SysVersionControlMorphxRevisionTable out C:\Data\testdata1.dat -T -d sourceDatabase -S sourceDBServer -N
bcp dbo.testdb2.SysVersionControlMorphxRevisionTable in C:\Data\testdata2.dat -T -d targetDatabase -S targetDBServer -N
//Destination DB
SELECT MIN(RecId) AS DestMinRecId FROM SysVersionControlMorphXRevisionTable
//Source DB
SELECT MAX(RecId) AS SourceMaxRecId From SysVersionControlMorphXRevisionTable
valueToAdd = (maxSourceRecId – minTargetRecId) + 1
//Update SQL Query in Destination DB
UPDATE SysVersionControlMorphXRevisionTable
SET RecId = RecId + valueToAdd
UPDATE SystemSequences
SET NEXTVAL = (SELECT MAX(RecId) + 1 FROM SYSVERSIONCONTROLMORPHXREVISIONTABLE) WHERE tabid = 2543
//BCP - bulk Copy Data
//BCP syntax : bcp <table_name> <direction> <file_name> <options>
options
[-n native type] [-c character type] [-S server name] [-U username]
[-P password] [-T trusted connection]
bcp dbo.testdb.SysVersionControlMorphxRevisionTable out C:\Data\testdata1.dat -T -d sourceDatabase -S sourceDBServer -N
bcp dbo.testdb2.SysVersionControlMorphxRevisionTable in C:\Data\testdata2.dat -T -d targetDatabase -S targetDBServer -N
No comments:
Post a Comment