I've restored SQL server database where it enabled SQL Broker Services. Now in Restored Database I need to re-enable these service in SQL Broker, after some online research I came to know that executing one or more query listed below might helps,
ALTER DATABASE [dbname] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [dbname] SET DISABLE_BROKER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [dbname] SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
Now in what order I need to execute these Queries, I have two questions :
- What will be the first query I need to execute
- What will be the last query I required to execute?
I'd do none of the above. Specifically, if I was trying to ensure that Service Broker was enabled after a restore, I'd specify that in the restore command. Either of:
What informs the choice of which to use? If you want the restored database to maintain the same Service Broker identifier (GUID) after restore and keep any in-flight messages that were present when the backup was taken, use the first. If you want it to generate a new GUID and clear the in-flight messages, use the second.