NAVDBCopy.sql

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2014-05-12 in Download section
NAVDBCopy.sql
NAV DB Copy - Copy companies between databases

This script is a solution for copying companies between databases on the same server or between linked servers. It can also be used to downgrade a SQL database from 2012 to 2008.

Since the Backup and Restore feature has been removed in NAV 2013 R2, I was searching for an alternative way to copy companies between databases. Among the goals were to support linked servers and to be a SQL only solution which could potentially be automated later on.

Usage:

1) Create an exact copy of the source database, all tables must be identical. Importing the objects as FOB is fine. This will be the destination database
2) Connect to the new database using the Windows Client and create a new Company. It must have exactly the same name as the Company in the source database
3) Open this script in a new Query Window in SQL Server Management Studio
4) Set the name of the destination database below ("USE DATABASENAME...")
5) Scroll down and set the name of the source database. You may also specify a linked server if the source database is on a remote SQL Server
6) Set the name of the company to copy
7) Optional: Specify all the DataPerCompany=No tables that you want to copy along by adding one "EXECUTE NAVCopyTable..." per table. Examples can be found below
8 ) Run the script to start the copy

http://www.mibuso.com/dlinfo.asp?FileID=1583

Discuss this download here.

Comments

  • mdPartnerNLmdPartnerNL Member Posts: 802
    Thx, for this solution.

    Its called DBCopy but after further reading its a company copy, which is good :)

    Do you have any ideas on how to save the original source first in this script? take to customer and then execute the rest of this script?

    Would this be possible?
  • papillonpapillon Member Posts: 8
    Do you have any ideas on how to save the original source first in this script? take to customer and then execute the rest of this script?
    Well, there is only one "part" to this script. So you copy it to the destination server and run it in SQL Management Studio after setting the necessary parameters (server, database, and company names) first. That is all, no further preparation needed.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    no, I mean save company to disk, then take to customer..
  • papillonpapillon Member Posts: 8
    Not supported by this script. But you could simply transport a SQL backup to the customer for this purpose and then run the script on that copy.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    The db is 40Gb and I only need to upload 1 company :? I guess I need to these steps twice: copy company to a new db, make small backup, restore backup, then copy. :o

    a .fbk used to be so easy.
Sign In or Register to comment.