sql server - How to use SQL conditional statements -


When executing an update query, I must delete a row based on values ​​in the column. Here's the code:

  UPDATE tag SET tag_count = tag_count - 1 WHERE tag_ID = 1 if the tag is counted & lt; Remove 1 from tag where tag_ id = 1  

this query gives me an error.

Edit I am using Inline SQL with C # sql server

In general, the best option updates and a transaction in these cases:

BEGIN transfer; Tag tag tag with tag ccc_count = tag_count - 1 WHERE tag_id = 1 with DELETE tag where tag_ id = 1 and tag_account & lt; 1; Committed transactions;

Comments

Popular posts from this blog

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -

tsql - Correct sql/hql query (aggregate in where clause) -