Create an ActiveX Script Job Step
This topic describes how to create and define a Microsoft SQL Server Agent job step in SQL Server 2012 that executes an ActiveX script by using SQL Server Management Studio, Transact-SQL, or SQL Server Management Objects.
Before you begin:
Limitations and Restrictions
Security
To create a Transact-SQL job step, using:
SQL Server Management Studio
Transact-SQL
SQL Server Management Objects
Before You Begin
Limitations and Restrictions
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
Security
For detailed information, see Implement SQL Server Agent Security.
[Top]
Using SQL Server Management Studio
To create an ActiveX Script job step
In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
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.
In the Job Properties dialog, click the Steps page, and then click New.
In the New Job Step dialog, type a job Step name.
In the Type list, click ActiveX Script.
In the Run as list, select the proxy account with the credentials that the job will use.
Select the Language in which the script was written. Alternatively, click Other and then enter the name of the Microsoft ActiveX scripting language in which the script will be written.
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.
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 SQL Server Agent should try to execute the job step, and how often retry attempts should be made.
[Top]
Using Transact-SQL
To create an ActiveX Script job step
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
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).
[Top]
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. For more information, see SQL Server Management Objects (SMO).
[Top]