If you are using the Dynamics AX built in MorphX Version Control System in your development environment, you may well encounter the need to move the version control history to another AX database instance at some point. For example, as part of our recent code upgrade from Dynamics AX 2012 to Dynamics AX 2012 R2 we wanted to retain our version history but jettison the remaining AX application data which was full of junk developer data in any case. Here’s how I achieved it using the SQL Server bcp utility. Note that this method assumes that the version control data on the target database is empty.
First you’ll need to log onto the database server that contains your source application database. Then open a Windows command prompt window and run the following bcp commands to extract the version control data from your source AX application database (Note: in commands I’ve used the name “sourceDatabase” as the name of the database. You’ll need to change it to the name of your AX database. e.g. “DynamicsAX”)…
bcp dbo.SysVersionControlMorphxItemTable out vcsitem.dat -T -d sourceDatabase -S localhost -N bcp dbo.SysVersionControlMorphxLockTable out vcslock.dat -T -d sourceDatabase -S localhost -N bcp dbo.SysVersionControlMorphxRevisionTable out vcsrev.dat -T -d sourceDatabase -S localhost -N
This will create three files; vcsitem.dat, vcslock.dat and vcsrev.dat. Now you can use these files to load this data into the target database using the following bcp commands (as before change the database name “targetDatabase” to the name of your target database. e.g. “DynamicsAXR2”).
bcp dbo.SysVersionControlMorphxItemTable in vcsitem.dat -T -d targetDatabase -S localhost -N bcp dbo.SysVersionControlMorphxLockTable in vcslock.dat -T -d targetDatabase -S localhost -N bcp dbo.SysVersionControlMorphxRevisionTable in vcsrev.dat -T -d targetDatabase -S localhost -N
These commands assume that both the source and target databases are on the same SQL Server. If your target database is actually on a different server then you need only change the –S argument of the commands. e.g.
bcp dbo.SysVersionControlMorphxItemTable in vcsitem.dat -T -d targetDatabase -S targetDBServer -N bcp dbo.SysVersionControlMorphxLockTable in vcslock.dat -T -d targetDatabase -S targetDBServer -N bcp dbo.SysVersionControlMorphxRevisionTable in vcsrev.dat -T -d targetDatabase -S targetDBServer -N
That’s all there is to it! Your version control items, history and any locks for currently checked out items will have been moved to the target system. If you don’t want to keep the check out locks for some reason, simply skip the bcp command for dbo.SysVersionControlMorphXLockTable.