tags:

views:

35

answers:

3

Hi, in my procedure, I try to run itself recursively when some conditions appear

(I simplified the code just to find out how to do the recursion)

Firstly I created the procedure with commented the BEGIN..END body, and then:

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

but I see an error inside BEGIN..END Incorrect syntax near 'dbo'. So how to solve it ?

+3  A: 

Add EXEC command and remove the parentheses around parameters:

EXEC [dbo].[insert_new_customer_task]
     @TaskTypeID, @TaskName,@IDCsrUser,@TaskStatusID,@ActualDateParam,1
Developer Art
+2  A: 

I think you need EXEC and no brackets on the parameters, i.e.

EXEC [dbo].[insert_new_customer_task] @TaskTypeID,@TaskName,
     @IDCsrUser,@TaskStatusID,@ActualDateParam,1
Rup
Worked perfectly, thanks !
Tony
+1  A: 
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

you need parenthesis around procedure definition, not in body where you call it.

Yossarian