2011-07-15 169 views
1
ALTER PROCEDURE dbo.ModeratorSpamDeleteComment 


    DECLARE @CommentID int; 



AS 
    BEGIN 
    DELETE Comments 
    WHERE [email protected] 
    END 

它說我有一個不正確的語法附近「AS」和「聲明」 ..問題與存儲過程

我要投放的存儲過程的參數CommentID並執行delete語句..

回答

3
ALTER PROCEDURE 
     dbo.ModeratorSpamDeleteComment 
       @CommentID INT 
AS 
     DELETE 
     FROM Comments 
     WHERE CommentsID = @CommentID 
2

剛剛擺脫申報:

ALTER PROCEDURE dbo.ModeratorSpamDeleteComment 
@CommentID int 
AS 


    BEGIN 
    DELETE Comments 
    WHERE [email protected] 
    END 
2

不要DECLARE參數;

ALTER PROCEDURE dbo.ModeratorSpamDeleteComment 
(--parens are optional but clearer imo 
    @CommentID int 
) 
AS --don't need BEGIN/END in this case 

DELETE FROM Comments 
    WHERE [email protected] 
1

移動DECLARE到你的過程體(BEGINEND之間)。它現在的區域是程序參數。