Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Power Expand / Collapse
Author
Message
Posted Thursday, July 31, 2008 9:07 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, August 1, 2014 3:00 AM
Points: 216, Visits: 33
Comments posted to this topic are about the item Power
Post #544825
Posted Friday, August 1, 2008 12:13 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, May 21, 2014 2:01 AM
Points: 797, Visits: 1,040
Both the correct answer and an error is returned:

Msg 232, Level 16, State 3, Line 2
Arithmetic overflow error for type int, value = 2147483648.000000.
Post #544863
Posted Friday, August 1, 2008 1:35 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, February 7, 2014 4:32 AM
Points: 227, Visits: 33
well i got only error.
safe way is select power(2.0,31)
Post #544892
Posted Friday, August 1, 2008 6:34 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 12:58 PM
Points: 2,561, Visits: 3,842
I got what JWOL got. SQL Server reported both the overflow error and the correct answer. A bit schizophrenic perhaps? ;)

This serves to show that one needs to be cognizant of data types and how they work. Learning is fun-damental. :D
Post #545068
Posted Friday, August 1, 2008 6:38 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, September 18, 2014 11:32 AM
Points: 2,669, Visits: 779
A bit unnerving to answer this one... is it for Windows SQL Server 7.0, 2000, 2005, 2008 - did they change anything to allow it to work in some cases and not in others? Would it be a different answer if I set my options to be non-backward compatible to version 8 (from version 9). And so on. VERY pleased that this question was not a trick question.

Jamie
Post #545071
Posted Friday, August 1, 2008 7:05 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 6, 2009 1:29 PM
Points: 2,057, Visits: 215
Yes, the error message includes the correct answer, but the SELECT statement didn't return anything.
Post #545093
Posted Friday, August 1, 2008 8:57 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: 2 days ago @ 10:23 PM
Points: 624, Visits: 228
This will also work:
SELECT power(cast(2 as bigint),31)



Post #545215
Posted Friday, August 1, 2008 9:01 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 4:16 PM
Points: 31,018, Visits: 15,456
Strangely enough, the answer returns in the error message.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #545219
Posted Friday, August 1, 2008 10:57 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, August 26, 2008 2:25 PM
Points: 10, Visits: 30
If the correct answer is returned in the error message why not just return the answer and gorget about the error. Obviously the user intended to return an answer without needing to specifically declare a type. What's the point of knowing the answer and returning an error? When I program an application I try to anticipate what the user wants and give it to him/her. I don't chastise them for asking incorrectly.
Post #545315
Posted Friday, August 1, 2008 11:34 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 3:41 PM
Points: 1,410, Visits: 8,095
The correct answer was returned with the error message but exceeded the maximum value allowed for that data type. That is why the result had to be an error.



Alvin Ramard
Memphis PASS Chapter

All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.
Post #545340
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse