Possible Duplicate:
Atomic UPSERT in SQL Server 2005
I am using the following construct to insert a new record if it does not exists. If it exists then it will update that record. I am wondering that if it is thread safe. I mean two threads try to insert record which will create duplicate entries. What is the best approach to handle such type of queries? Do I need to put these statements in a transaction block?
UPDATE Table1 SET (...) WHERE Column1='SomeValue'
IF @@ROWCOUNT=0
INSERT INTO Table1 VALUES (...)