Monday, 19 April 2010

TSQL query update in trascaction

When updating a live DB, use the following query. Once data looks ok, hilight commit and run (or rollbak if it's not good)

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
BEGIN TRAN

-- update
update table
set stuff = 'something'
WHERE active = 1 AND
code LIKE 'VCH%'

-- check changes
SELECT *
FROM COM_Voucher
order by active, end_date

--commit
--rollback