How to apply a SQL script

KB ID: 1443
Products: Veeam Backup & Replication;Veeam ONE
Version: All
Published:
Last Modified: 2017-01-31

Purpose

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

Solution

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:

https://www.veeam.com/kb1761
 

3 / 5 (11 votes cast)

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!

Orphus system