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 984797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:04:08+00:00 2026-05-16T05:04:08+00:00

I have a Constraint on a table with IGNORE_DUP_KEY. This allows bulk inserts to

  • 0

I have a Constraint on a table with IGNORE_DUP_KEY. This allows bulk inserts to partially work where some records are dupes and some are not (only inserting the non-dupes). However, it does not allow updates to partially work, where I only want those records updated where dupes will not be created.

Does anyone know how I can support IGNORE_DUP_KEY when applying updates?

I am using MS SQL 2005

  • 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-16T05:04:09+00:00Added an answer on May 16, 2026 at 5:04 am

    If I understand correctly, you want to do UPDATEs without specifying the necessary WHERE logic to avoid creating duplicates?

    create table #t (col1 int not null, col2 int not null, primary key (col1, col2))
    
    insert into #t 
    select 1, 1 union all 
    select 1, 2 union all 
    select 2, 3
    
    -- you want to do just this...
    update #t set col2 = 1
    
    -- ... but you really need to do this
    update #t set col2 = 1
    where not exists (
        select * from #t t2
        where #t.col1 = t2.col1 and col2 = 1
        )
    

    The main options that come to mind are:

    1. Use a complete UPDATE statement to avoid creating duplicates
    2. Use an INSTEAD OF UPDATE trigger to ‘intercept’ the UPDATE and only do UPDATEs that won’t create a duplicate
    3. Use a row-by-row processing technique such as cursors and wrap each UPDATE in TRY…CATCH… or whatever the language’s equivalent is

    I don’t think anyone can tell you which one is best, because it depends on what you’re trying to do and what environment you’re working in. But because row-by-row processing could potentially produce some false positives, I would try to stick with a set-based approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
I have a table like this: CREATE TABLE [dbo].[TRACEABLE]( [TRACEABLE_ID] [uniqueidentifier] NOT NULL CONSTRAINT
I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT
I have a table like this: CREATE TABLE [dbo].[Scores]( [Id] [int] IDENTITY(1,1) NOT NULL,
If I have that constraint on a table, (field1 is null and field2 is
I have a constraint (named INVS_ITEM_LOCATIONS_PK ) in my SQL Server 2005 table. How
I have a database table that has a Unique Key constraint defined to avoid
I have a custom table created which has a foreign constraint on the core_website
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have a table like so.. CREATE TABLE [dbo].[Locations_Hours]( [LocationID] [int] NOT NULL, [sun_open]

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.