Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem with POWER

Problem with POWER

Scheduled Pinned Locked Moved Database
helpdatabasesql-serversysadminquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheComputerMan
    wrote on last edited by
    #1

    I am getting an error message in an SQL statement that I don't understand This is the statement: UPDATE [QVSData].[dbo].[tbl_CentCatalogQVS] SET [Energy] = (POWER(10,(4.8+([Magnitude]*1.5))))/POWER(10,3) WHERE [AutoID] = 1 This is just a test hence restricted to 1 line to see if it works. It does not, and I am scratching my head as to why not. This is the error: Arithmetic overflow error for type int, value = 1995262314968882.700000 There is no int in the table. The affected fields here are: The Mag field is a decimal field (10,4) with in this instance a value of 7.0000 The energy field is a decimal field (20,1) Anyone have any ideas as to why this error is appearing? Actually I make that value 1995262314968.8 so it seems that it is possibly falling over as it calculates the first part before doing the division to get to Kilojoules. Why is it using int? To make it easier to figure out this error occurs if you run this: DECLARE @mag decimal(10,4) DECLARE @energy decimal(20,1) SET @mag = 7 SET @energy = (POWER(10,(4.8+(@mag*1.5))))/POWER(10,3) SELECT @energy The you get: Msg 232, Level 16, State 3, Line 5 Arithmetic overflow error for type int, value = 1995262314968882.700000. (1 row(s) affected) And the value is NULL Sorry forgot to add: SQL Server 2005 Developer Edition

    T D 2 Replies Last reply
    0
    • T TheComputerMan

      I am getting an error message in an SQL statement that I don't understand This is the statement: UPDATE [QVSData].[dbo].[tbl_CentCatalogQVS] SET [Energy] = (POWER(10,(4.8+([Magnitude]*1.5))))/POWER(10,3) WHERE [AutoID] = 1 This is just a test hence restricted to 1 line to see if it works. It does not, and I am scratching my head as to why not. This is the error: Arithmetic overflow error for type int, value = 1995262314968882.700000 There is no int in the table. The affected fields here are: The Mag field is a decimal field (10,4) with in this instance a value of 7.0000 The energy field is a decimal field (20,1) Anyone have any ideas as to why this error is appearing? Actually I make that value 1995262314968.8 so it seems that it is possibly falling over as it calculates the first part before doing the division to get to Kilojoules. Why is it using int? To make it easier to figure out this error occurs if you run this: DECLARE @mag decimal(10,4) DECLARE @energy decimal(20,1) SET @mag = 7 SET @energy = (POWER(10,(4.8+(@mag*1.5))))/POWER(10,3) SELECT @energy The you get: Msg 232, Level 16, State 3, Line 5 Arithmetic overflow error for type int, value = 1995262314968882.700000. (1 row(s) affected) And the value is NULL Sorry forgot to add: SQL Server 2005 Developer Edition

      T Offline
      T Offline
      TheComputerMan
      wrote on last edited by
      #2

      Yes I am replying to myself! This fixed it DECLARE @mag decimal(10,4) DECLARE @energy decimal(20,1) DECLARE @log float SET @log = 10 SET @mag = 7 SET @energy = (POWER(@log,(4.8+(@mag*1.5))))/POWER(@log,3) SELECT @energy

      S 1 Reply Last reply
      0
      • T TheComputerMan

        Yes I am replying to myself! This fixed it DECLARE @mag decimal(10,4) DECLARE @energy decimal(20,1) DECLARE @log float SET @log = 10 SET @mag = 7 SET @energy = (POWER(@log,(4.8+(@mag*1.5))))/POWER(@log,3) SELECT @energy

        S Offline
        S Offline
        SilimSayo
        wrote on last edited by
        #3

        From your subject line I thought don't like people in positions of power/government/ etc :)

        1 Reply Last reply
        0
        • T TheComputerMan

          I am getting an error message in an SQL statement that I don't understand This is the statement: UPDATE [QVSData].[dbo].[tbl_CentCatalogQVS] SET [Energy] = (POWER(10,(4.8+([Magnitude]*1.5))))/POWER(10,3) WHERE [AutoID] = 1 This is just a test hence restricted to 1 line to see if it works. It does not, and I am scratching my head as to why not. This is the error: Arithmetic overflow error for type int, value = 1995262314968882.700000 There is no int in the table. The affected fields here are: The Mag field is a decimal field (10,4) with in this instance a value of 7.0000 The energy field is a decimal field (20,1) Anyone have any ideas as to why this error is appearing? Actually I make that value 1995262314968.8 so it seems that it is possibly falling over as it calculates the first part before doing the division to get to Kilojoules. Why is it using int? To make it easier to figure out this error occurs if you run this: DECLARE @mag decimal(10,4) DECLARE @energy decimal(20,1) SET @mag = 7 SET @energy = (POWER(10,(4.8+(@mag*1.5))))/POWER(10,3) SELECT @energy The you get: Msg 232, Level 16, State 3, Line 5 Arithmetic overflow error for type int, value = 1995262314968882.700000. (1 row(s) affected) And the value is NULL Sorry forgot to add: SQL Server 2005 Developer Edition

          D Offline
          D Offline
          dasblinkenlight
          wrote on last edited by
          #4

          Dividing by 10^3 is the same as subtracting 3 from 4.8+(@mag*1.5), so you should be able to avoid overflow if you rewrite your expression as follows:POWER(10,(1.8+(@mag*1.5))).

          T 1 Reply Last reply
          0
          • D dasblinkenlight

            Dividing by 10^3 is the same as subtracting 3 from 4.8+(@mag*1.5), so you should be able to avoid overflow if you rewrite your expression as follows:POWER(10,(1.8+(@mag*1.5))).

            T Offline
            T Offline
            TheComputerMan
            wrote on last edited by
            #5

            Thank you. Seems a good scheme. I have absolutely no idea how you came up with that. Maths is not one of my strong points!

            D 1 Reply Last reply
            0
            • T TheComputerMan

              Thank you. Seems a good scheme. I have absolutely no idea how you came up with that. Maths is not one of my strong points!

              D Offline
              D Offline
              dasblinkenlight
              wrote on last edited by
              #6

              TheComputerMan wrote:

              I have absolutely no idea how you came up with that.

              It's one of three main identities of exponentiation[^].

              TheComputerMan wrote:

              Maths is not one of my strong points!

              Math is no longer required: you can type in your formula, and let a computer simplify it for you[^] :)

              T 1 Reply Last reply
              0
              • D dasblinkenlight

                TheComputerMan wrote:

                I have absolutely no idea how you came up with that.

                It's one of three main identities of exponentiation[^].

                TheComputerMan wrote:

                Maths is not one of my strong points!

                Math is no longer required: you can type in your formula, and let a computer simplify it for you[^] :)

                T Offline
                T Offline
                TheComputerMan
                wrote on last edited by
                #7

                We live and learn and live to learn another day! Thanks again. Once I have uncrossed by eyes I will see if I can assimilate any of that and become 1 of 10^666 Neat PDF that on Wolfram. Devilishly cunning stuff!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups