Updating a table from another table

The CTE result set is derived from a simple query and is referenced by UPDATE statement.

updating a table from another table-45updating a table from another table-83updating a table from another table-48

Let suppose that someone has accidentally updated all esql Sales Person. How can we easily repopulate this data without having to retype it in?

The reason we’re using a table variable is temporary and will be removed once query session is closed.

Specifies the temporary named result set or view, also known as common table expression (CTE), defined within the scope of the UPDATE statement.

The UPDATE statement is complex and there are many elements to consider. For a full list check out the UPDATE (Transact-SQL) article.

Keep in mind that when updating data in columns whose data type is CHAR, VARCHAR, or VARBINARY, the padding or truncation of data depends upon the SET ANSI_PADDING setting.

Leave a Reply