Having issue with sqldatacompare CMD to generate insert scripts for data
Cho
Posts: 4 New member
Hello! I am trying to generate schema and data scripts using CMD "sqlcompare" and "sqldatacompare". The following "sqlcompare" command worked for me for generating the schema script and place them into a script folder:
> .\sqlcompare /Server1:MyServer01 /Database1:MyDatabase /makescripts:"\\MyServer01\My_SQL_Compare_BackUp\MyDatabase_20211021"
However, the "sqldatacompare" command below doesn't create the INSERTs script for me in the folder, when I run it, it only generate the schema scripts:
> .\sqldatacompare /Server1:MyServer01 /Database1:MyDatabase /makescripts:"\\MyServer01\My_SQL_Compare_Backup\MyDatabase_20211021"
Is there something I am missing in my sqldatacompare command?
Thanks!
> .\sqlcompare /Server1:MyServer01 /Database1:MyDatabase /makescripts:"\\MyServer01\My_SQL_Compare_BackUp\MyDatabase_20211021"
However, the "sqldatacompare" command below doesn't create the INSERTs script for me in the folder, when I run it, it only generate the schema scripts:
> .\sqldatacompare /Server1:MyServer01 /Database1:MyDatabase /makescripts:"\\MyServer01\My_SQL_Compare_Backup\MyDatabase_20211021"
Is there something I am missing in my sqldatacompare command?
Thanks!
Tagged:
Best Answer
-
Kurt_M Posts: 209 Silver 1Hi @Cho
Could you try the following to see if this works for you:
sqldatacompare /Server1:<server name> /Database1:<database name> /Scripts2:<path to scripts folder> /Synchronize
Kind regards,
Kurt McCormick
Product Support Engineer, RedgateNeed help? Take a look at our Help Center
Answers
Hi Cho,
Instead of the /makescripts option, you'll actually need to use the /scriptfile option instead. I have pasted below a simple amendment of your command which shows how the /scriptfile option is to be used. You'll notice it's not much different from the /makescripts option. Using this should resolve your issue.
> .\sqldatacompare /Server1:MyServer01 /Database1:MyDatabase /Database2:MyDatabase2 /scriptfile:"\\MyServer01\My_SQL_Compare_Backup\MyDatabase_20211021\script.sql"
Below is the explanation on this option which can be found through the following command: sqlcompare /help /verbose.
/scriptfile:<scriptfile>
Alias:
/sf
Writes SQL change migration script to specified file.
This option allows you to generate an SQL script to migrate the changes which can be executed at a later time. If the file already exists an error will occur, unless you have also used the /force switch.
Also, a helpful tip that I use:
You can output the help list to HTML by using this: sqlcompare /help /verbose /html /out:C:\help.html
I find it makes it far easier to read and to search.
Kind regards,
Kurt McCormick
Product Support Engineer, Redgate
Need help? Take a look at our Help Center
Product Manager
Redgate Software