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

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -