Incrementing an Integer in SQL Server -
Any HTML question here, every time I change a specific record in a SQL Server 2008 R2 table, I want to increase a RevisionId record. I
; To do this, I am using the following syntax:
updateTable SET RevisionId = (SELECT RevisionId to be set WHERE id = @ id) +1 WHERE id = @ id; BTW, I'm putting it in a trigger so that it is done automatically, but when this code works, it sounds too tight - is there a cleaner way to do this?
You do not need internal selection:
Update Table SET RevisionId = RevisionId + 1 WHERE ID = @ ID
Comments
Post a Comment