40

Is it possible to suppress warnings generated by T-SQL scripts? If so, how?

I know I can turn of the 'records affected' messages with

SET NOCOUNT ON

but is there an equivalent for warnings? Eg:

Warning: Null value is eliminated by an aggregate or other SET operation.

If I'm expecting these errors, it helps to sift the real errors from the chaff in a big script.

Thanks.

AR.
  • 39,615
  • 9
  • 44
  • 52

1 Answers1

50

See SET ANSI_WARNINGS {ON | OFF}

BraveNewMath
  • 8,090
  • 5
  • 46
  • 51
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • 15
    While this answer is perfectly valid I want to add something: Setting ANSI_WARNINGS has lots of other behavior changes and disables certain features. Changing it to a nonstandard value is likely to break stuff in other places. I would consider it to be bad practice to use it. – usr Mar 24 '13 at 21:08
  • 12
    Please add a little more flesh to your link-only answer. Thanks. – juergen d Sep 10 '13 at 12:32
  • 4
    So is it on or off? (hint: it's `off`) a binary answer is not an answer. I'm not sure how a weblink got upvoted 43 times. – Nick.Mc Dec 12 '16 at 06:45