How to apply a SQL script

KB ID: 1443
Product: Veeam Backup & Replication;Veeam ONE
Version: All
Last Modified: 2017-08-07


Instructions to run a SQL script against a MS SQL database.


To run a SQL script from a command line, please perform the following steps:

  1. Save the script as *.sql file (e.g. script.sql) to local disk
  2. Make sure that no jobs are running
  3. Run the following command:
    sqlcmd -S <SqlServerName>\<SqlInstanceName> -d <SqlDatabaseName> -i PATHTOSCRIPT\script.sql -o c:\resetresult.txt -I

         HKLM\Software\VeeaM\Veeam Backup and Replication\SqlServerName
         HKLM\Software\VeeaM\Veeam Backup and Replication\SqlInstanceName
         HKLM\Software\VeeaM\Veeam Backup and Replication\SqlDatabaseName

         If the script needs to be applied to EM database, please use:
         HKLM\Software\VeeaM\Veeam Backup Reporting\SqlServerName
         HKLM\Software\VeeaM\Veeam Backup Reporting\SqlInstanceName
         HKLM\Software\VeeaM\Veeam Backup Reporting\SqlDatabaseName
  4. Restart the Veeam services

You may also run a SQL script from SQL Server Management Studio, right click on your database and choose the “New query” option, insert the text from the file, and click Execute.
SQL Server Management Studio can be found here:

Rate the quality of this KB article: 
3.8 out of 5 based on 19 ratings

Couldn't find what you were looking for?

Below you can submit an idea for a new knowledge base article.

Request new content

Report a typo on this page:

Please select a spelling error or a typo on this page with your mouse and press CTRL + Enter to report this mistake to us. Thank you!

Spelling error in text: