Updating rows in sql
Using T-SQL to insert, update, or delete large amounts of data from a table will results in some unexpected difficulties if you’ve never taken it to task.
Let’s say you have a table in which you want to delete millions of records.
In this article I will demonstrate a fast way to update rows in a large table Consider a table called which has more than 5 millions rows.
Suppose you want to update a column with the value 0, if it that column contains negative value.
Order ID == 11000 select ord; // Execute the query, and change the column values // you want to change. Ship Via = 2 ' Insert any additional changes to column values.
Combine the top operator with a while loop to specify the batches of tuples we will delete.
For more information, see WITH common_table_expression (Transact-SQL). For information about table hints, see Table Hints (Transact-SQL).
TOP ( ) Specifies one or more table hints that are allowed for a target table. @ Note When referencing the Unicode character data types nchar, nvarchar, and ntext, 'expression' should be prefixed with the capital letter 'N'.
He now has good level of knowledge in SQLServer, Oracle, My SQL and Postgre SQL as well.
He is also one of the leading posters at a moderator at