Sunday, March 26, 2017

Preventing duplicate RecId - Copying version control from Source to Target (Version Control Data) AX

//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

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...