Pergunta

I am creating an application with Sql cached dependency.

For this i enabled the broker by

Alter database test ENABLE_BROKER

After i add two new tables to the database.

But i found that i am not able to get any notification services for the new tables that i added.

Even i use

Alter datatbase test New_Broker

THis command keeps on running so i cancel it without any success.

Can you please specify what i am missing

Any help is apprciated

Foi útil?

Solução

It seems like you're asking two questions:

  1. How to prevent SET ENABLE_BROKER from hanging

    ALTER DATABASE [YourDBName] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE

  2. Can you get notified by Service Broker when the schema changes?

Notifications are for existing tables only. This might lead you to consider trying to register a dependency against sys.tables, but system views and tables are not allowed in a query for notifications.

You should be able to work around this by setting up a DDL trigger that inserts into a special table, and then issue queries against that table. For example:

CREATE TRIGGER [MyTrigger] ON DATABASE AFTER CREATE_TABLE AS ...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top