Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is UPDATE containing .WRITE clause atomic when multiple columns are updated?

Tags:

sql

sql-server

Is the following statement an atomic operation?

UPDATE [table1]
SET column1=@val1, column2.WRITE(@val2, NULL, 0) WHERE table1_id=@id

or should it be placed inside a transaction to ensure that none or both columns are updated in case of error situations?

Columns are defined as:

column1 int not null, 
column2 varbinary(max) not null 
like image 299
kuniklo Avatar asked Dec 06 '25 00:12

kuniklo


1 Answers

It is one statement. In SQL Server, each statement carries an implied transaction. Here is another answer if you'd like more details.

What does a transaction around a single statement do?

like image 61
tommy_o Avatar answered Dec 08 '25 14:12

tommy_o



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!