4/1/2018
Posted by 
Sql Update Multiple Rows Single Query Definition Rating: 4,9/5 2893reviews
See More On StackoverflowGive More Feedback

Hi, you can basically use this pattern: UPDATE TLRT_MR SET MS_EFEN = TLR_EFEN WHERE TLR_STA_C = 'MS' AND TLR_EFEN IS NOT NULL; UPDATE TLRT_MR SET MS_ERRN = TLR_ERRN WHERE TLR_STA_C = 'MS' AND TLR_ERRN IS NOT NULL; -- becomes UPDATE TLRT_MR SET MS_EFEN = CASE WHEN TLR_EFEN IS NULL THEN MS_EFEN ELSE TLR_EFEN END, MS_ERRN = CASE WHEN TLR_ERRN IS NULL THEN MS_ERRN ELSE TLR_ERRN END WHERE TLR_STA_C = 'MS'; But it may have consequences when there are triggers and/or indices on this columns. Btw, why want you to do that?

In SQL, is it possible to update entries in multiple rows of the same column, in a single statement? UPDATE: Thanks to Mohit Vazir and Swastik Bhat for reminding me.

It looks like you should reconsider your data model, it seems to me that you have stored multiple entities in your table. Microsoft MVP Office Access https://mvp.support.microsoft.com/profile/Stefan.Hoffmann. >>I have very large query that updates several values in one table.

>In its current form, I'm sure it's pretty inefficient. >I've included the query below. Is there any way to UPDATE several values in one SQL statement, versus having a separate UPDATE statement for each value I'm updating? >>I have very large query that updates several values in one table. >In its current form, I'm sure it's pretty inefficient. >I've included the query below.

Is there any way to UPDATE several values in one SQL statement, versus having a separate UPDATE statement for each value I'm updating? Hi, you can basically use this pattern: UPDATE TLRT_MR SET MS_EFEN = TLR_EFEN WHERE TLR_STA_C = 'MS' AND TLR_EFEN IS NOT NULL; UPDATE TLRT_MR SET MS_ERRN = TLR_ERRN WHERE TLR_STA_C = 'MS' AND TLR_ERRN IS NOT NULL; -- becomes UPDATE TLRT_MR SET MS_EFEN = CASE WHEN TLR_EFEN IS NULL THEN MS_EFEN ELSE TLR_EFEN END, MS_ERRN = CASE WHEN TLR_ERRN IS NULL THEN MS_ERRN ELSE TLR_ERRN END WHERE TLR_STA_C = 'MS'; But it may have consequences when there are triggers and/or indices on this columns. Btw, why want you to do that?

It looks like you should reconsider your data model, it seems to me that you have stored multiple entities in your table. Microsoft MVP Office Access https://mvp.support.microsoft.com/profile/Stefan.Hoffmann. Ew100 G1 Manual. .and I can GUARANTEE that you don't address people like this in person. I know if anyone ever talked to me the way you choose to 'talk' to people on this board, suffice it to say, it wouldn't happen again. I've found a bunch of your other replies, and why MSDN forums continues to allow you to berate,belittle, and abuse other posters on here is beyond me. Robinson Unfortunately some of the stuff Celko say's is correct and good advice however when it’s mixed in with insults and belittling, all it does is make people angry so his advice goes out the window.

This type of behaviour is generally a result of Tall Poppy Syndrome. Each post has a “Report as Abuse” option where you report something as “Profanity” or “Other Term of Use or Code of Conduct Violation” so you are well within your rights to report his reply. Jeff Wharton MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt) MCT, MCPD, MCITP, MCDBA Blog: Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker. I can completely see where what may be said - from a technical perspective - is correct.but that outburst was completely and utterly disrespectful. That kind of clap-trap has no place in a forum meant to help and inform others. I don't care how much of an expert someone is, that was completely and utterly out of line and uncalled for. Robinson That's why I stated 'when it’s mixed in with insults and belittling' so I acknowledged that he didn't treat you well.

Jeff Wharton MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt) MCT, MCPD, MCITP, MCDBA Blog: Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker.