Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

update or insert sql

begin tran
if exists (select * from table with (updlock,serializable) where key = @key)
begin
   update table set ...
   where key = @key
end
else
begin
   insert into table (key, ...)
   values (@key, ...)
end
commit tran
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #insert #sql
ADD COMMENT
Topic
Name
9+6 =