June 10, 2015 at 10:57 pm
Comments posted to this topic are about the item Error handling
June 10, 2015 at 11:50 pm
Thanks for this easy question.
June 11, 2015 at 2:06 am
Only an easy question if you know all of the SQL Server error codes. Otherwise the only way to get it right is to cheat and run the code.
June 11, 2015 at 4:10 am
This was removed by the editor as SPAM
June 11, 2015 at 5:52 am
I suppose you could run the following for each of the messages listed:
select * from sys.messages where message_id = n;
Either way, it was a nice, clear question. Thanks.
June 11, 2015 at 6:59 am
I think that the explanation should be expanded to include what exactly error code 220 means.
Error Code 220 is an arithmetic overflow error.
June 11, 2015 at 7:05 am
I knew it would error with some kind of overflow error but I don't have all the error codes memorized.
June 11, 2015 at 7:15 am
Iwas Bornready (6/11/2015)
I knew it would error with some kind of overflow error but I don't have all the error codes memorized.
+1
Figured it out by elimination:
1000 - wrong
220 - no clue
255 - max tinyint value
Error - different type then @@ERROR
Therefore, 220, which I had no clue about must the correct error code for this question.
June 11, 2015 at 8:46 am
doug.davidson (6/11/2015)
Iwas Bornready (6/11/2015)
I knew it would error with some kind of overflow error but I don't have all the error codes memorized.+1
Figured it out by elimination:
1000 - wrong
220 - no clue
255 - max tinyint value
Error - different type then @@ERROR
Therefore, 220, which I had no clue about must the correct error code for this question.
Unfortunately, I couldn't be sure that 1000 and 255 were coincidences with the error code.
June 11, 2015 at 9:45 am
select * from sys.messages where message_id = 220;
It says, "Arithmetic overflow error for data type %ls, value = %ld."
Good one.
Thanks.
June 11, 2015 at 9:48 am
I also had to consult the table. Thanks, Junior!
June 11, 2015 at 2:58 pm
error is obviously wrong, and if 1000 were the message number for tinyint overflow this would be a disgraceful trick queston and I don't mind getting those wrong, 255 (the limit of tinyint) would be a strange coincidence so it seemed worth going for 220.
It's interesting to see that SQL Server, even in it's 64 bit form, still thinks in terms of 32 bit integers so that the message when feeding in 2147483648 for a tinyint or smallint is quite different from that got by feeding in 2147483647 or lower - message number 8115 instead of 220.
Tom
June 12, 2015 at 2:52 am
It returns indeed 220, but that is an errornumber.
So I doubted whether 220 or error.
I have chosen 220.
June 12, 2015 at 5:56 am
Hi Tom,
Thanks for post, I agree with you.
June 16, 2015 at 4:42 am
Nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply