enable sql server notification sql 的通知功能需要的最小权限

原文:http://hi.baidu.com/cairabbit/blog

use XXXX

-- configure database to enable .net clr support
EXEC sp_configure 'show advanced options' , '1';
go
reconfigure;
go
EXEC sp_configure 'clr enabled' , '1'
go
reconfigure;
go
-- enable database using broker
ALTER DATABASE XXXX SET ENABLE_BROKER
go
-- set database trustworthy
ALTER DATABASE XXXX SET TRUSTWORTHY ON
go
-- you can check if the database broker enabled
--select is_broker_enabled from sys.databases where name = 'XXXX'

---- add notification accounts, if the application logged the database as sa,
---- it's not necessary to create these accounts.

CREATE USER [notifier] FOR LOGIN [sa]
WITH DEFAULT_SCHEMA = [notification]
GO
CREATE SCHEMA [notification] AUTHORIZATION [notifier]
GO

EXEC sp_addrole 'sql_dependency_subscriber'
GO

-- grant privilege to the login user (if you are logged in as sa(dbo), this is not necessary)
GRANT CREATE PROCEDURE TO sql_dependency_subscriber
GRANT CREATE QUEUE TO sql_dependency_subscriber
GRANT CREATE SERVICE TO sql_dependency_subscriber
GRANT REFERENCES on CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] to sql_dependency_subscriber
GRANT VIEW DEFINITION TO sql_dependency_subscriber
GRANT SELECT to sql_dependency_subscriber

GRANT SUBSCRIBE QUERY NOTIFICATIONS TO sql_dependency_subscriber
GRANT RECEIVE ON QueryNotificationErrorsQueue TO sql_dependency_subscriber
GO

EXEC sp_addrolemember 'sql_dependency_subscriber', 'notifier'
GO

--exec sp_helprotect NULL, 'sql_dependency_subscriber'

-- query currently subscriptions
--SELECT * FROM sys.dm_qn_subscriptions
--KILL QUERY NOTIFICATION SUBSCRIPTION 42

--select * from sys.internal_tables

-- query the undelivered subscripted notification
--SELECT * FROM sys.transmission_queue

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值