Skip to main content
SQL: If Exists Update Else Insert
Entry Date: Rate:
Site:
Keywords:
RSS Description:

This is a pretty common situation that comes up when performing database operations. A stored procedure is called and the data needs to be updated if it already exists and inserted if it does not.

Comments:

Exists and Insert or Update does not perform well, this entry has a very simple tip that implements this scenario in a simple, elegant and efficient way (try an update if rowcount is zero then go for insert, cool ! :-))