Updating multiple rows at a time in sql server

Rated 3.89/5 based on 694 customer reviews

I am trying to write an update query with this as the basic concept: UPDATE Table1SET Flag Entity = 0WHERE (ID = 1) or (ID =2)I get an Execution error stating that the subquery cannot return more than one value if I use =. -- Paul Fleming At best you can say that one job may be more secure than another, but total job security is an illusion. ----------------------------------------------------------------------------------Your lack of planning does not constitute an emergency on my part...unless you're my manager..a director and above..a really loud-spoken end-user.. Jack Corbett Consultant Straight Path Solutions Dont let the good be the enemy of the best.

I also provide examples that demonstrate how the various clauses work.

-- Rod at work Check out these links on how to get faster and more accurate answers: Forum Etiquette: How to post data/code on a forum to get the best help Need an Answer? You Need a Question How to Post Performance Problems Crosstabs and Pivots or How to turn rows into columns Part 1Crosstabs and Pivots or How to turn rows into columns Part 2 A single update query can update all of the rows in a table if you so desire.

The fact that you're getting errors as to sub-queries is simply telling that a. you're using them in such a way that they would require a single value. How about you post what you've tried so far so that we can help you with the specific problem?

If you include multiple sets, you simply separate the sets with commas.

For instance, the following example updates the Sales Quota, Sales YTD, and Sales Last Year columns: expression for each column/value pair.

Leave a Reply