Scripting (Service Broker)

SQL Server Service Broker is a part of the Database Engine and uses the same two types of scripting used by the Database Engine. SQL Server PowerShell scripts are used to manage instances of the Database Engine and the Service Broker objects in the instances. Database Engine Query scripts can contain Transact-SQL statements that manage Service Broker objects.

Database Engine Scripting

Service Broker is managed in the following ways:

  • The SQL Server PowerShell provider includes Service Broker objects in the SQL Server paths it implements. You can use the sqlps utility to interactively build and test PowerShell commands that work with Service Broker objects. You can build PowerShell script files that work with Service Broker objects, and then run the files using the sqlps utility or as input to SQL Server Agent PowerShell job steps.

  • Transact-SQL statements that can be interactively built and tested in the Database Engine Query Editor in SQL Server Management Studio or the sqlcmd utility. Transact-SQL statements built in the editor can be saved in script files. The files can later be run using sqlcmd, the Database Engine Query Editor, or the SQL Server PowerShell Invoke-Sqlcmd cmdlet.

For more information about scripting support for the Database Engine, see Scripting (Database Engine).