Skip to content

Latest commit

 

History

History
95 lines (63 loc) · 4.55 KB

create-an-activex-script-job-step.md

File metadata and controls

95 lines (63 loc) · 4.55 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
Create an ActiveX Script Job Step
Create an ActiveX Script Job Step
markingmyname
maghan
10/06/2020
sql
ssms
how-to
ActiveX scripting jobs [SQL Server]
job steps [Analysis Services]
<= sql-server-2016

Create an ActiveX script job step

[!INCLUDE sqlserver]

ActiveX subsystem is discontinued beginning with SQL Server 2016. Convert any existing job steps that use ActiveX Script to a PowerShell script job step. Use PowerShell for any future development.

Important

On Azure SQL Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Managed Instance from SQL Server for details.

This topic describes how to create and define a [!INCLUDEmsCoName] [!INCLUDEssNoVersion] Agent job step in SQL Server 2014 and prior that executes an ActiveX script by using SQL Server Management Studio, [!INCLUDEtsql], or SQL Server Management Objects.

Before you begin

Limitations and Restrictions

[!INCLUDEssNoteDepFutureAvoid]

Security

For detailed information, see Implement SQL Server Agent Security.

Use SQL Server Management Studio

To create an ActiveX Script job step

  1. In Object Explorer, connect to an instance of the [!INCLUDEssDEnoversion], and then expand that instance.

  2. Expand SQL Server Agent, create a new job or right-click an existing job, and then click Properties. For more information on creating a job, see Creating Jobs.

  3. In the Job Properties dialog, click the Steps page, and then click New.

  4. In the New Job Step dialog, type a job Step name.

  5. In the Type list, click ActiveX Script.

  6. In the Run as list, select the proxy account with the credentials that the job will use.

  7. Select the Language in which the script was written. Alternatively, click Other and then enter the name of the [!INCLUDEmsCoName] ActiveX scripting language in which the script will be written.

  8. In the Command box, enter the script syntax that will be executed for the job step. Alternately, click Open and select a file containing the script syntax.

  9. Click the Advanced page to set the following job step options: what action to take if the job step succeeds or fails, how many times [!INCLUDEssNoVersion] Agent should try to execute the job step, and how often retry attempts should be made.

Using Transact-SQL

To create an ActiveX script job step

  1. In Object Explorer, connect to an instance of [!INCLUDEssDE].

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    -- create an ActiveX Script job step written in VBScript that creates a restore point  
    USE msdb;  
    GO  
    EXEC sp_add_jobstep  
        @job_name = N'Weekly Sales Data Backup',  
        @step_name = N'Create a restore point',  
        @subsystem = N'ACTIVESCRIPTING',  
        @command = N'Const RESTORE_POINT = 20  
    
    strComputer = "."  
    Set objWMIService = GetObject("winmgmts:" _  
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")  
    
    Set objItem = objWMIService.Get("SystemRestore")  
    errResults = objItem.Restore(RESTORE_POINT)',   
        @retry_attempts = 5,  
        @retry_interval = 5 ;  
    GO  
    

For more information, see sp_add_jobstep (Transact-SQL).

Using SQL Server Management Objects

To create an ActiveX Script job step

Use the JobStep class by using a programming language that you choose, such as Visual Basic, Visual C#, or PowerShell.