Solutions for INSERT OR UPDATE on SQL Server

0 votes

Consider the MyTable table structure. I frequently want to either insert a new record if one doesn't already exist or edit an existing record.

Essentially:

IF (key exists)
  run update command
ELSE
  run insert command

What would be the most effective way to write this?

Aug 27 in Database by Kithuzzz
• 11,640 points
15 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

How to upsert (update or insert) in SQL Server 2005

Try to check for existence: IF NOT EXISTS ...READ MORE

answered Sep 18 in Database by narikkadan
• 19,680 points
19 views
0 votes
0 answers

SQL Server Cannot perform an aggregate function on an expression containing an aggregate or a subquery

Error: Cannot perform an aggregate function on an ...READ MORE

Aug 18 in Database by Kithuzzz
• 11,640 points
47 views
0 votes
0 answers

SQL Server 2008 - IF NOT EXISTS INSERT ELSE UPDATE

I'm trying to create a time clock ...READ MORE

Aug 28 in Database by Kithuzzz
• 11,640 points
37 views
0 votes
1 answer
0 votes
1 answer

Install MS-SQL Server on Windows

Follow these steps  if you wish to ...READ MORE

answered Mar 18, 2019 in Database by Kiran
355 views
0 votes
0 answers

Which SQL server should we use for SQL queries to be executed?

I mean to say which SQL server ...READ MORE

Aug 18, 2019 in Database by Sonali
223 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9 in Database by Neha
• 8,920 points
161 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9 in Database by Neha
• 8,920 points
102 views
0 votes
1 answer

Inserting multiple rows in a single SQL query?

In SQL Server 2008, multiple rows can ...READ MORE

answered Feb 10 in Database by Vaani
• 7,020 points
82 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

Your dates are interpreted as MM-DD-YYYY. This ...READ MORE

answered Jun 21 in Others by nisha
• 2,180 points
46 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP