I am using SMO objects to access my database. I have service broker enabled on SQL Server. I was wondering if anyone knew how to enable/disable queue's through code (VB/C#). I've tried ServiceQueue.IsEnqueueEnabled
but this only sets the the property.
The property that controls the STATUS = {ON | OFF}
is indeed .IsEnqueueEnabled
. But all SMO modifications are in-memory only until the .Alter()
method is called:
The Alter method updates any changes that have been made to the ServiceQueue object's properties since the ServiceQueue object was created or since the last Alter statement.
This is the general way of interacting with SMO objects, changes are in-memory only until explicitly applied.
In case your curious why the property is called IsEnqueueEnabled
the short answer is that the name (properly) reflects the column name of sys.service_queues.is_enqueue_enabled
. The long asnwer is that the column is so named because once upon a time queues had the capability to be disabled separately for enqueue and for dequeue. The separation did not made the light of 2005 RTM but the traces were left in the catalog view.