Sql updating a row
Common table expressions can also be used with the SELECT, INSERT, DELETE, and CREATE VIEW statements.For more information, see WITH common_table_expression (Transact-SQL). For information about table hints, see Table Hints (Transact-SQL).One lets you assign specific values to columns by name; the other lets you assign a list of values (that might be returned by a statement) to a list of columns.
With Update Data As ( SELECT RS_NOM, ROW_NUMBER() OVER (ORDER BY [RS_NOM] DESC) AS RN FROM DESTINATAIRE_TEMP ) UPDATE DESTINATAIRE_TEMP SET CODE_DEST = RN FROM DESTINATAIRE_TEMP INNER JOIN Update Data ON DESTINATAIRE_TEMP. RS_NOM By adding a WHERE clause I found the performance improved massively for subsequent updates.
DEFAULT Specifies that the default value defined for the column is to replace the existing value in the column.
Compound assignment operator: = Add and assign -= Subtract and assign *= Multiply and assign /= Divide and assign %= Modulo and assign &= Bitwise AND and assign ^= Bitwise XOR and assign |= Bitwise OR and assign Returns updated data or expressions based on it as part of the UPDATE operation.
In the demonstration database, the customer.customer_num column is the primary key for that table, so this statement can update no more than one row.
You can also use subqueries in the specifies a new value for a column.