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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:16:17+00:00 2026-06-18T04:16:17+00:00

I currently have a SQL insert into statement that copies items from one identical

  • 0

I currently have a SQL insert into statement that copies items from one identical table to another.

The source table has many identical records or records that may have small variations.

Example…

The source and destination table are in the format:

ItemDATE // ItemTIME // SITENAME // SERIAL_NO // RPM // Power // Voltage1 // Voltage2 // etc

The source may contain:

ItemDATE // ItemTIME // SITENAME // SERIAL_NO // RPM // Power // Voltage1 // Voltage2 // etc

2013-01-01 00:00:00.000 // 17:00:00.1 // Oxford College // 0014617 // 1500 // 250 // 250.8 // 249.2
2013-01-01 00:00:00.000 // 17:00:00.1 // Oxford College // 0014617 // 1499// 249 // 253.5 // 240.6
2013-01-01 00:00:00.000 // 17:00:00.1 // Oxford College // 0014617 // 1502// 251 // 239.8 // 269.8

My insert statement is:

INSERT INTO ReportingSystem.dbo.HistoryLog(ItemDATE, ItemTIME, SITENAME, SERIAL_NO, RPM, Power, Voltage1, Voltage2)
SELECT ItemDATE, ItemTIME, SITENAME, SERIAL_SN, RPM, Power, Voltage1, Voltage2      
FROM ReportingSystem.dbo.RTCU

EXCEPT
SELECT ItemDATE, ItemTIME, SITENAME, SERIAL_SN, RPM, Power, Voltage1, Voltage2
FROM ReportingSystem.dbo.HistoryLog

Where HistoryLog is the destination and RTCU is the source.

I am not concerned about the different values in the RPM, Power, Voltage1 and Voltage2 fields but there should be no records where the itemDATE, ItemTIME, SITENAME and SERIAL_NO are the same.

But with the Except statement I am still getting duplicated as it considers the entire record.

I have tried the following with no success:

INSERT INTO HistoryLog
(ItemDATE, ItemTIME, SITENAME, SERIAL_NO, RPM, Power, Voltage1, Voltage2)

SELECT ItemDATE, ItemTIME, SITENAME, SERIAL_NO, RPM, Power, Voltage1, Voltage2
FROM RTCU
WHERE not exists (select * from HistoryLog
WHERE HistoryLog.ItemDATE = rtcu.ItemDATE
and HistoryLog.ItemTIME = rtcu.ItemTIME
and HistoryLog.SITENAME = rtcu.SITENAME 
and HistoryLog.SERIAL_NO= rtcu.SERIAL_NO
);

Please help….

  • 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-18T04:16:18+00:00Added an answer on June 18, 2026 at 4:16 am
    INSERT INTO dbo.HistoryLog
    (
      ItemDATE, ItemTIME, 
      SITENAME, SERIAL_NO, 
      RPM, Power, Voltage1, Voltage2
    )
    SELECT 
      ItemDATE, ItemTIME, 
      SITENAME, SERIAL_NO, 
      RPM, Power, Voltage1, Voltage2
    FROM 
    (
      SELECT 
        ItemDATE, ItemTIME, 
        SITENAME, SERIAL_NO, 
        RPM, Power, Voltage1, Voltage2,
        rn = ROW_NUMBER() OVER 
        (
          PARTITION BY ItemDATE, ItemTIME, 
            SITENAME, SERIAL_NO
          ORDER BY RPM DESC
        )
      FROM dbo.RTCU
    ) AS RTCU
    WHERE rn = 1
    AND NOT EXISTS 
    (
      SELECT 1 FROM dbo.HistoryLog
        WHERE ItemDATE  = rtcu.ItemDATE
          AND ItemTIME  = rtcu.ItemTIME
          AND SITENAME  = rtcu.SITENAME 
          AND SERIAL_NO = rtcu.SERIAL_NO
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL statement like that: INSERT INTO TABLE_3(TABLE_1ID, TABLE_2ID) SELECT ID FROM
I currently have this sql statement that I wrote and it works but it's
I currently have two SQL commands. One retrieves a list of unique IDs from
I have an sql statement that currently is just returning all the end parent
Currently I have a powershell proccess that is scanning a SQL Server Table and
I am currently running the following SQL statement on my MySQL database: INSERT INTO
I am trying to add a key from one table to another so that
I have a SQL script that inserts data (via INSERT statements currently numbering in
I currently have a SQL query that returns a number of fields. I need
I currently have the following SQL query that lists all the names of all

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.