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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:11:50+00:00 2026-05-15T01:11:50+00:00

I have a big fat query that’s written dynamically to integrate some data. Basically

  • 0

I have a big fat query that’s written dynamically to integrate some data. Basically what it does is query some tables, join some other ones, treat some data, and then insert it into a final table.

The problem is that there’s too much data, and we can’t really trust the sources, because there could be some errored or inconsistent data.

For example, I’ve spent almost an hour looking for an error while developing using a customer’s database because somewhere in the middle of my big fat query there was an error converting some varchar to datetime. It turned out to be that they had some sales dating ‘2009-02-29’, an out-of-range date.
And yes, I know. Why was that stored as varchar? Well, the source database has 3 columns for dates, ‘Month’, ‘Day’ and ‘Year’. I have no idea why it’s like that, but still, it is.

But how the hell would I treat that, if the source is not trustable?

I can’t HANDLE exceptions, I really need that it comes up to another level with the original message, but I wanted to provide some more info, so that the user could at least try to solve it before calling us.

So I thought about displaying to the user the row number, or some ID that would at least give him some idea of what record he’d have to correct. That’s also a hard job because there will be times when the integration will run up to 80000 records.
And in an 80000 records integration, a single dummy error message: ‘The conversion of a varchar data type to a datetime data type resulted in an out-of-range datetime value’ means nothing at all.

So any idea would be appreciated.

Oh I’m using SQL Server 2005 with Service Pack 3.


EDIT:

Ok, so for what I’ve read as answers, best thing to do is check each column that could be critical to raising errors, and if they do attend the condition, I should myself raise an error, with the message I find more descriptive, and add some info that could have been stored in a separate table or some variables, for example the ID of the row, or some other root information.

  • 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-15T01:11:50+00:00Added an answer on May 15, 2026 at 1:11 am

    This sounds like a standard ETL issue: Extract, Transform, and Load. (Unless you have to run this query over and over again against the same set of data, in which case you’d pretty much do the same thing, only over and over again. So how critical is performance?)

    What kind of error handling and/or “reporting of bad data” are you allowed to provide? If you have everything as “one big fat query”, your options become very limited — either the query works or it doesn’t, and if it doesn’t I’m guessing you get at best one RAISERROR message to tell the caller what’s what.

    In a situation like this, the general framework I’d try to set up is:

    • Starting with the source table(s)
    • Produce an interim set of tables (SQLMenace’s staging tables) that you know are consistant and properly formed (valid data, keys, etc.)
    • Write the “not quite so big and fat query” against those tables

    Done this way, you should always be able to return (or store) a valid data set… even if it is empty. The trick will be in determining when the routine fails — when is the data too corrupt to process and produce the desired results, so you return a properly worded error message instead?

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

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer 80k lines isn't large enough that you can't load it… May 15, 2026 at 1:17 pm
  • Editorial Team
    Editorial Team added an answer Replace inFile with inputFile. May 15, 2026 at 1:17 pm
  • Editorial Team
    Editorial Team added an answer It a more obvious way: $data = array(); while($row =… May 15, 2026 at 1:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.