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, 2022 in Database by Kithuzzz
• 38,000 points
753 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, 2022 in Database by narikkadan
• 63,600 points
673 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, 2022 in Database by Kithuzzz
• 38,000 points
1,299 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, 2022 in Database by Kithuzzz
• 38,000 points
4,216 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
767 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
534 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, 2022 in Database by Neha
• 9,020 points
1,346 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, 2022 in Database by Neha
• 9,020 points
759 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, 2022 in Database by Vaani
• 7,070 points
1,039 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, 2022 in Others by nisha
• 2,210 points
592 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP