sql server - Select and update in single query -


I have a contact-name email that the phone message is emailed as an email, after answering default message The area is empty, a special message that I am updating that area, but at the same time I want to get other values ​​such as name and select the e-mail statement

< P>

Are you saying that you have more than one line OE or are only updated one?

If you are updating multiple rows, you can select the affected row ID in the temporary table, update

if you are updating a row, then Just make a selection on that line after the update.

It is a bad thing to try two operations at the same time, as long as the logic of the situation does not make it clear, later, it is necessary.

You always have a simple last updated DATETIME field table. So you just need a variable that you set on getdate () and use it during the update. After updating, just return each row, where the last updated match matches the variable.

Example:

  Declare the @optime datetime @optime = getdate () Update .... (...., last updated) value (.. ..., @ opetime) * Select ... from ... where the last update = @optime  

Comments