I am using SQL Server 2008 R2 and I want to create a stored procedure that deletes from two tables using a paramater (id).
This is the stored procedure:
CREATE PROCEDURE [dbo].[sp_deleteDecision]
@ID int
AS
DELETE FROM [dbo].[tblDecisionInvolvement] as di
WHERE di.DecisionId = @ID
DELETE FROM [dbo].[tblDecision] as d
WHERE d.Id =@ID
GO
This is the error I get when I try to create it:
Msg 156, Level 15, State 1, Procedure sp_deleteDecision, Line 6
Incorrect syntax near the keyword 'as'.
Msg 156, Level 15, State 1, Procedure sp_deleteDecision, Line 8
Incorrect syntax near the keyword 'as'.
Note that changing the DELETE FROM to
SELECT * FROM
it works.
Is it even possible to delete something using parameters?
Ty.
ASin a delete this way? Did you look at the official documentation for theDELETEcommand when you encountered this error?