Update Top 1 record in table sql server [duplicate]
WITH UpdateList_view AS (
SELECT TOP 1 * from TX_Master_PCBA
WHERE SERIAL_NO IN ('0500030309')
ORDER BY TIMESTAMP2 DESC
)
update UpdateList_view
set TIMESTAMP2 = '2013-12-12 15:40:31.593'
Accepted answer of Kapil is flawed, it will update more than one record if there are 2 or more than one records available with same timestamps, not a true top 1 query.
;With cte as (
SELECT TOP(1) email_fk FROM abc WHERE id= 177 ORDER BY created DESC
)
UPDATE cte SET email_fk = 10
Ref Remus Rusanu Ans:- SQL update top1 row query