Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Promoting all Warnings to Errors - SQL 2005

Status
Not open for further replies.

ousoonerjoe

Programmer
Jun 12, 2007
925
0
0
US
Is it possible to promote all warnings to act as Errors? We have discovered a scenario where a warning will fire, but does not cause an error and in turn causes invalid data to be written to the record. In this particular case, addition between 3 variables and one of them comes up NULL. Any math with a NULL results with a NULL regardless. This causes a warning to fire, but not an error. TRY and CATCH skip right on past these.

The warning states something about Aggregates with NULL result in NULL. Obviously i can do ISNULL for the short fix, but I'd like to get these warnings to act as errors for future issues other than just this one.

Any assistance, tips, or ideas are welcome and appreciated.

Thank you.

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
Tried that. It just ignores the warnings. I need them to be promoted to full Error status.

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
Right, I don't think it's an easy task. Unless there is a way to catch all warnings and then raise error.

You can get warnings from ASP.NET as far as I know using some class. I can do a bit of a research on this, if needed, I remember this problem discussed on another forum.
 
I'm needing them to report in Stored Procedures regardless of what calls them, primarily. All I need are the statements to halt and drop down into the CATCH block and ROLL BACK. That way I can prevent corrupt data from being compounded and inserted into the tables.

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top