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

  • Home
  • SEARCH
  • 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 7730307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:11:35+00:00 2026-06-01T06:11:35+00:00

I have a table with 10 million records with a nonclustered index key on

  • 0

I have a table with 10 million records with a nonclustered index key on one column and I am trying to dedupe the table. I tried the inserts with select where either using a left join or where not exists; but each time I get the error with violation of key. Here are the queries I used;

insert into temp(profile,feed,photo,dateadded) 
select distinct  profile,feed,photo,dateadded from original as s 
where not exists(select 1 from temp as t where t.profile=s.profile) 

This just produces the violation of key error. I tried using the following:

insert into temp(profile,feed,photo,dateadded) 
select distinct    profile,feed,photo,dateadded from original as s  
left outer join temp t on t.profile=s.profile 
where t.profile is null 

I ended using a batch insert since the log file was growing too big but still get the violation of primary key error even on only 1000 records.

Destination Table :IX_Temp - profileUrl(ASC)--> unique key (non clustered)
Source Table: IX_PURL - profileUrl(ASC) ---> index (non clustered, not unique 
  • 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-06-01T06:11:36+00:00Added an answer on June 1, 2026 at 6:11 am

    I imagine that distinct isn’t working as you expect here as the time portion will be slightly different.

    A different approach would be to use group by and take the earliest dateadded to remove any duplicates.

    Maybe something like this:

    Select Profile,
           Feed,
           Photo,
           Min(DateAdded) as [DateAdded]
    
    From Original
    Group By Profile, Feed, Photo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table with almost 2 million records on my SQLite database, some
I have a table now containing over 43 million records. To execute SELECT ,
I have a table of 26 million records, and wanted to add some columns
I have a table with 5 million records of dates stored as char(10) with
I have a table with 42 million records. 32 million have a null value
I have a table with 10 million records with no indexes and I am
I have a table with more than 1 million records. The problem is that
I have a mysql table with over 30 million records that was originally being
I have about 1 million records in my contact table in the DB, now
I have a table with 15,000,000 records. These records can be related to one-another

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.