How to apply a SQL script

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

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
 

How helpful is this article: 
3.6 out of 5 based on 15 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!

Orphus system