mia domandaAggiornamento Top 1 record nella tabella SQL Server
UPDATE TOP (1) TX_Master_PCBA
SET TIMESTAMP2 = '2013-12-12 15:40:31.593'
WHERE SERIAL_NO IN ('0500030309')
ORDER BY TIMESTAMP2 DESC
con serial_No
Colonna nella tabella TX_Master_PCBA
Ho 10 record, ma voglio aggiornare l'ultima TIMESTAMP2
a datetime corrente.
query precedente sta gettando errore:
Sintassi non corretta in prossimità della parola chiave 'TOP'.
possibile duplicato di [? UPDATE TOP SQL con ORDER BY] (http://stackoverflow.com/questions/19584315/sql-update-top-with-order-by) – GolfWolf
sebbene la domanda indichi SQL-SERVER, per chi ricerca la soluzione MySql c'è un modo più semplice e veloce 'UPDATE TX_Master_PCBA SET TIMESTAMP2 = NOW() WHERE SERIAL_NO = '050030309' ORDINA BY TIMESTAMP DESC LIMIT 1' –
Possibile duplicato di [SQL update top1 row query] (http: // stackov erflow.com/questions/3860975/sql-update-top1-row-query) – fabriciorissetto