title: Running a script inside a transaction T-SQL
body: <p>Is it possible to run a script inside a transaction?
  Then I could just edit the path to the script and run them in a secure way.</p>
  
  <pre><code>:setvar ScriptPath "C:\Script1.sql"
  BEGIN TRY
      BEGIN TRANSACTION
          :r $(ScriptPath)
      COMMIT TRANSACTION
      PRINT 'Successfull'
  END TRY
  BEGIN CATCH
      PRINT 'Error'
      ROLLBACK TRANSACTION
  END CATCH
  </code></pre>
  
  <p>But I get the following errors as soon as I try running a script in the transaction:
  Incorrect syntax near 'BEGIN'.
  Incorrect syntax near 'TRY'.
  Incorrect syntax near 'CATCH'.</p>