我正在使用SQL Server 2012 Express。「服務代理」服務器主體「sa」無法在當前安全環境下訪問數據庫
我正在使用Service Broker異步運行存儲過程。
激活過程必須訪問另一個數據庫才能執行另一個存儲過程。這是代碼:
CREATE PROCEDURE [dbo].[GetNewCodes]
@gintNewCodes bigint,
@presNewCodes tinyint,
@levelNewCodes bigint,
@quantityNewCodes smallint
AS
-- Get new codes from INCIC database.
DECLARE @return_value int,
@xmlGenerated xml,
@xmlString NVARCHAR(MAX)
SET NOCOUNT ON;
-- Set that this stored procedure is running
update dbo.RunningSPs with (serializable) set conf_value = 1
where sp_name = N'GetNewCodes'
if @@rowcount = 0
begin
insert dbo.RunningSPs(sp_name, conf_value) values (N'GetNewCodes', 1)
end
EXEC @return_value = [INCIC].[dbo].[ReadCodeBuffer]
@gint = @gintNewCodes,
@pres = @presNewCodes,
@level = @levelNewCodes,
@quantity = @quantityNewCodes,
@xmlGenerated = @xmlGenerated OUTPUT
SET @xmlString = cast(@xmlGenerated as nvarchar(max))
-- Process these new codes on TRZ.
EXEC dbo.ProcessCodes @XmlString = @xmlString
-- Update that we are not running this procedure any more.
update dbo.RunningSPs with (serializable) set conf_value = 0
where sp_name = N'GetNewCodes'
if @@rowcount = 0
begin
insert dbo.RunningSPs(sp_name, conf_value) values (N'GetNewCodes', 0)
end
的問題是在這裏:[INCIC].[dbo].[ReadCodeBuffer]
,並且錯誤信息是:
Error: 50000
Unrecoverable error in procedure GetNewCodes: 916: The server principal "sa" is not able to access the database "INCIC" under the current security context.
我跟了這tutorial實施服務,隊列和激活存儲過程。
我該如何解決這個問題?