Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6108761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:19:49+00:00 2026-05-23T14:19:49+00:00

I am basically trying to do the thing from MYSQL where it is INSERT

  • 0

I am basically trying to do the thing from MYSQL where it is INSERT and ON DUPLICATE, etc.

However, I am getting an error with my ‘merge’ syntax. This stored procedure takes a variable “@ID” which is a guid and looks in the table to see if it exists already — if it does, insert a new entry, otherwise update the existing. I can’t figure out what is wrong here!

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE usp_DigitalTool_InsertUpdate2
(@ID uniqueidentifier, @TOOL_ID uniqueidentifier, @INPUT_ID uniqueidentifier)

AS

MERGE 
INTO  DigitalTool as target
USING (SElECT @ID,@TOOL_ID,@INPUT_ID) as source(id, tool_id, input_id) 
ON (target.ID = source.id)
when matched then  
 update
  set TOOL_ID = source.tool_id,
    INPUT_ID = source.input_id
when not matched then
insert ( ID, TOOL_ID, INPUT_ID)
    values ( NEWID(), source.tool_id, source.input_id)

END
GO

Help is appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:19:50+00:00Added an answer on May 23, 2026 at 2:19 pm

    Using TSQL You can use the EXISTS keyword to determine whether a record is found as follows.

    IF EXISTS(
     SELECT 1
     FROM MY_TABLE
     WHERE ITEM='somevalue' AND ENTERDATE='12/31/1999')
        --Update Statement
        UPDATE MY_TABLE
        SET ITEM='anothervalue'
        WHERE ITEM='somevalue' AND ENTERDATE='12/31/1999'
    ELSE
        --Insert Statement
        INSERT INTO MY_TABLE
        (ITEM, ENTERDATE)
        VALUES
        ('somevalue', '12/31/1999')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've learned a lot from this forum, and thanks in advance. Basically, I'm trying
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am trying to write an Add-In to PowerPoint that does basically one thing:
I'm basically trying to figure out the simplest way to perform your basic insert
I recently came across this in some code - basically someone trying to create
I'm trying to convert this to dwoo: foreach($duplicates as $duplicate) { echo <tr>; foreach($column_list
When trying to search for this specific thing I'd like to do, I end
I am trying to duplicate a drop down list with jquery. Basically I want
I'm trying to parse data from the web, basically, from an API (Google Finance
I'm basically trying to teach myself how to code and I want to follow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.