Wednesday 8 February 2012

Enable Service Broker in SQL Server painlessly

Every so often, I find myself having to create a new testing, staging, whatever non-live environment for an application.  Often I forget that Service Broker needs to be enabled at the database level before it can be used - a database restore doesn't do this.

So often I'm hunting around for a code snippet to enable the Service Broker on a database that's already running (as usually it's the task I've forgotten to do earlier!)

Here's the code snippet:


ALTER DATABASE Titan_Reporting SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE Titan_Reporting SET ENABLE_BROKER
GO
ALTER DATABASE Titan_Reporting SET MULTI_USER
GO

Don't forget the 'WITH ROLLBACK IMMEDIATE', otherwise you'll be waiting a looooong time for the first statement to complete! 

1 comment:

  1. This, in particular, allows trading during news times with no restrictions on trading. An NDD broker can either charge commission for trading or choose to increase the spread and make Forex trading commission free. All Cargo Logistics And Shipping Services

    ReplyDelete