update top 100 order by sql server 1

update top 100 order by sql server

;WITH CTE AS 
( 
SELECT TOP 100 * 
FROM T1 
ORDER BY F2 
) 
UPDATE CTE SET F1='foo'

Here is what the above code is Doing:
1. Create a CTE (Common Table Expression) that selects the top 100 rows from T1, ordered by F2.
2. Update the CTE, setting F1 to ‘foo’.

Similar Posts