What permissions are needed for using SQLDependency? I checked books online but it wasn't clear on this point.
This works:
CREATE SCHEMA sql_dependency_user --empty placeholder schema
GO
CREATE LOGIN TEST_USER WITH PASSWORD=N'XXX', DEFAULT_DATABASE=[TestDatabase], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
CREATE USER TEST_USER FOR LOGIN TEST_USER
WITH DEFAULT_SCHEMA=[sql_dependency_user]
GO
GRANT CREATE PROCEDURE TO TEST_USER
GO
GRANT CONTROL ON SCHEMA::[sql_dependency_user] TO TEST_USER
GO
GRANT CREATE SERVICE TO TEST_USER
GO
GRANT CREATE QUEUE TO TEST_USER
GO
GRANT IMPERSONATE ON USER::dbo TO TEST_USER
GO
GRANT REFERENCES ON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] TO TEST_USER
GO
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO TEST_USER;
GO
GRANT SELECT ON SCHEMA::[dbo] TO TEST_USER
GO
GRANT RECEIVE on QueryNotificationErrorsQueue TO TEST_USER
I am not marking it as the answer yet because I don't know for a fact that all of those permissions are needed.
As far as I know, the user must have ALTER
permission, and in addition, you have to enable SERVICE BROKER
GRANT ALTER ON SCHEMA::dbo to myUser
ALTER DATABASE myDatabases SET ENABLE_BROKER;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With