2010-09-02 75 views
1

在我的過程中,我嘗試遞歸運行時本身一定條件下出現T-SQL如何遞歸運行過程?

(我簡化了代碼,只是找出如何做遞歸)

首先,我創建的過程帶有註釋的BEGIN .. END身體,然後:

alter PROCEDURE [dbo].[insert_new_customer_task] 
    @TaskTypeID decimal, 
    @TaskName nvarchar(1000), 
    @IDCsrUser decimal, 
    @TaskStatusID decimal, 
    @ActualDateParam datetime, 
    @isNextDate bit 
AS 
BEGIN 
     [dbo].[insert_new_customer_task](@TaskTypeID,@TaskName,@IDCsrUser,@TaskStatusID,@ActualDateParam,1) 
END 
GO 

但我看到BEGIN..END 附近有語法錯誤DBO「內部錯誤。那麼如何解決呢?

回答

2

我認爲你需要EXEC及參數沒有括號,即

EXEC [dbo].[insert_new_customer_task] @TaskTypeID,@TaskName, 
    @IDCsrUser,@TaskStatusID,@ActualDateParam,1 
+0

工作完美,謝謝! – Tony 2010-09-02 08:57:03

3

添加EXEC命令,並刪除括號周圍參數:

EXEC [dbo].[insert_new_customer_task] 
    @TaskTypeID, @TaskName,@IDCsrUser,@TaskStatusID,@ActualDateParam,1 
1
alter PROCEDURE [dbo].[insert_new_customer_task](
    @TaskTypeID decimal, 
    @TaskName nvarchar(1000), 
    @IDCsrUser decimal, 
    @TaskStatusID decimal, 
    @ActualDateParam datetime, 
    @isNextDate bit) 
AS 
BEGIN 
     EXEC [dbo].[insert_new_customer_task] @TaskTypeID,@TaskName,@IDCsrUser,@TaskStatusID,@ActualDateParam,1 
END 
GO 

你需要圍繞過程定義括號,而不是你稱之爲的身體。