Reputation: 2866
CREATE TABLE Post
(
postID - PK
memberID
title
thread
.
.
.
reported int DEFAULT 0,
dateCreated datetime DEFAULT GetDate() NOT NULL
);
I want to write a stored procedure that would raise "reported" field by 1 every-time i execute the procedure. Any idea?
Upvotes: 0
Views: 701
Reputation: 754538
How about:
CREATE PROCEDURE dbo.UpdateReported(@PostID INT)
AS BEGIN
UPDATE dbo.Post
SET Reported = Reported + 1
WHERE PostID = @PostID
END
You can then call that stored proc with:
EXEC dbo.UpdateReported @PostID = 5
or pass whatever PostID
you want to update...
Upvotes: 4