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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:35:45+00:00 2026-06-04T03:35:45+00:00

I have a SQL database that queries the history data of engines. One of

  • 0

I have a SQL database that queries the history data of engines. One of the features is that on a daily basis a stored procedure will search through all the data for a specific event and if the event is found it will insert it into a new table.

The problem is that this data must be unique…

The Table headers are as below:

ID / ID_Location / IDDown / IDUp / DtDown / DtUp / TimeDifference / IsExempt / Reason / Details / OrigDtUp 

And the SQL query is:

insert into exempts(ID_Location, iddown, idup, dtdown, dtup, timedifference) 
select ID_Location, iddown, idup, dtdown, dtup, DATEDIFF(MINUTE, dtdown, dtup) as timedifference 
from @tmptbl 
except 
select ID_Location, iddown, idup, dtdown, dtup, timedifference from exempts 

A user is able to make adjustments to some of these values such as the DtUp (The Time when the engine is back on-line). Once the DtUp value is changed the original DtUp value is stored in OrigDtUp field and the TimeDifference is updated according to DtDown and DtUp time variation.

So what I really need is this:

insert into exempts(ID_Location, iddown, idup, dtdown, dtup, timedifference) 
select ID_Location, iddown, idup, dtdown, dtup, DATEDIFF(MINUTE, dtdown, dtup) as timedifference 
from @tmptbl 
except 
select ID_Location, iddown, idup OR OrigDtUp, dtdown, dtup from exempts

Which we know is not supported by the except function in SQL??

  • 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-04T03:35:48+00:00Added an answer on June 4, 2026 at 3:35 am

    Couldn’t you except it twice?

    insert into exempts(ID_Location, iddown, idup, dtdown, dtup, timedifference) 
    select ID_Location, iddown, idup, dtdown, dtup, DATEDIFF(MINUTE, dtdown, dtup) as timedifference 
    from tmptbl 
    except 
    select ID_Location, iddown, idup, dtdown, dtup 
    from exempts
    except 
    select ID_Location, iddown, OrigDtUp, dtdown, dtup 
    from exempts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure in a MS-SQL 2005 database that: Creates two temp
I have several sql queries that I simply want to fire at the database.
I have a SQL Server 2000 database that will not display the column list
We have a SQL Server 2008 database that has stored procedures to handle reads/writes/etc.
Scenario: I have an application that pulls data from a SQL database as well
i have a asp.net mvc webpage that queries a SQL server database for contact
I have an excel document that queries an SQL Database on button press. The
I have a SQL database that has a table with a field set to
I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity
I have a typical dev scenario: I have a SQL 2008 database that I

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.