Updating multiple columns in sql
For more information, see OUTPUT Clause (Transact-SQL).
FROM Specifies that a table, view, or derived table source is used to provide the criteria for the update operation. If the object being updated is the same as the object in the FROM clause and there is only one reference to the object in the FROM clause, an object alias may or may not be specified.
For more information, see Query Hints (Transact-SQL). All char and nchar columns are right-padded to the defined length.
There is no limit to the number of predicates that can be included in a search condition.For example, in the UPDATE statement in the following script, both rows in USE Adventure Works2012; GO IF OBJECT_ID ('dbo. To replace or modify large blocks of text, ntext, or image data, use WRITETEXT or UPDATETEXT instead of the UPDATE statement.Table1', ' U') IS NOT NULL DROP TABLE dbo. Table2', ' U') IS NOT NULL DROP TABLE dbo. Table1 (Col A int NOT NULL, Col B decimal(10,3) NOT NULL); GO CREATE TABLE dbo. If the UPDATE statement could change more than one row while updating both the clustering key and one or more text, ntext, or image columns, the partial update to these columns is executed as a full replacement of the values.For more information, see @@ROWCOUNT (Transact-SQL). Variable names can be used in UPDATE statements to show the old and new values affected, but this should be used only when the UPDATE statement affects a single record. The Microsoft SQL Server ODBC driver and OLE DB Provider for SQL Server automatically set ANSI_PADDING ON for each connection.If the UPDATE statement affects multiple records, to return the old and new values for each record, use the OUTPUT clause. This can be configured in ODBC data sources or by setting connection attributes or properties.