2014-05-21 66 views
0

我無法更改服務代理存儲過程,當我更新存儲過程時,它不顯示任何錯誤併成功更新,但更改不會生效。SQL SERVER:更改服務代理存儲過程

是否因爲我需要在更改可能發生影響之前停止兩個數據庫上的服務代理隊列?

注意:服務代理存儲過程生成並讀取xml。

包括該存儲過程

ALTER PROCEDURE [dbo].[ServiceBroker_AtTarget_FromSLICJobEstimateDetailsNewLineAddedBySupplier] 
    @XML XML(SLICMessageSchema) 
AS 
BEGIN 
    -- extract data : 
    DECLARE  
    @LogNo    INT, 
    @QuoteReference   INT, 
    @JobEstimatesDetailID  INT, 
    @UserName   NVARCHAR(50), 
    @Description   NVARCHAR(MAX), 
    @UnitValue   DECIMAL(18,2), 
    @Quantity   DECIMAL(18,2), 
    @LineTotal   DECIMAL(18,2), 
    @QuoteTotal   DECIMAL(18,2), 
    @tsCreated   DATETIME 

    SELECT  @QuoteReference = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@QuoteReference)[1]', 'int'), 
      @JobEstimatesDetailID = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@JobEstimatesDetailID)[1]', 'int'),  
      @UserName = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@UserName)[1]', 'nvarchar(50)'), 
      @Description = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@Description)[1]', 'nvarchar(max)'), 
      @UnitValue = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@UnitValue)[1]', 'decimal(18,2)'), 
      @Quantity = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@Quantity)[1]', 'decimal(18,2)'),  
      @tsCreated = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@tsCreated)[1]', 'datetime') 

    SET @LogNo = (SELECT mlq.logno FROM fsgmgtservices.dbo.maintlogquotes mlq WHERE mlq.quoteno = @QuoteReference) 

    INSERT INTO fsgcentraldata.dbo.[tblSLICGeneratedEvents] 
    (EventNameID, tsCreated, CreatedBy, IsAcknowledged, JobNumber, ContractorID) 
    SELECT 9, @tsCreated, @UserName, 0, @LogNo, je.contractorid 
    FROM [slic3.0].dbo.JobEstimates je WHERE je.legacyreference = CAST(@quotereference AS varchar(50)) 



SET @LineTotal = (@UnitValue * @Quantity) // IF I CHANGE IT TO ((@UnitValue * 2)) FOR EXMPL 



    INSERT INTO fsgmgtservices.dbo.maintlogquotedetails 
    (quoteno, details, quantity, rate, amount, [date], slicreference) 
    SELECT @QuoteReference, @description, @quantity, @UnitValue, @LineTotal, @tscreated, @JobEstimatesDetailID 

    SET @QuoteTotal = (SELECT SUM(mlqd.amount) FROM fsgmgtservices.dbo.maintlogquotedetails mlqd 
    WHERE mlqd.quoteno = @QuoteReference) 

    UPDATE fsgmgtservices.dbo.maintlogquotes SET amount = @QuoteTotal WHERE quoteno = @QuoteReference 

    INSERT INTO [fsgmgtservices].[dbo].maintlognotes 
    (logno, [date], [user], [note], transferredfromslic) 
    SELECT @LogNo, @tsCreated, @UserName, 'Quote ' + CAST(@QuoteReference AS varchar(20)) + ', new lines added by supplier in SLIC By ' + @UserName , 0 

END 
+0

使用'sp_helptext'來驗證'ALTER'實際使用。或者,也許你正在查看錯誤的數據庫。 – usr

回答

2

改變活化的存儲過程不殺死任何正在運行的實例。很有可能您的舊代碼仍在循環運行,並且將繼續運行,直到它退出循環或者將其終止。

+0

嗨Remus,我等待隊列中的所有工作完成之前,我禁用了隊列,並修改了SP。我運行下面的命令,它說0.從sys.objects中選擇p.rows 作爲o 在p.object_id上加入sys.partitions作爲p.object_id 作爲q在o.parent_object_id = q上加入sys.objects。 object_id 其中,未將sp_helptext中的q.name ='queuename' 和p.index_id = 1 –

+0

存儲過程顯示爲由更新編輯時未被考慮。請注意有兩個數據庫環境都具有相同的事件和目標存儲過程 –

+1

服務代理程序1.不帶參數和2. **必須**發出['RECEIVE'](http://msdn.microsoft.com /en-us/library/ms186963.aspx)。您必須閱讀[Service Broker編程概念](http://technet.microsoft.com/zh-cn/library/ms171626.aspx) –