Results 1 to 9 of 9

Thread: SQL Calculation

  1. #1
    Join Date
    Oct 2009
    Posts
    93

    Unanswered: SQL Calculation

    Hi folks, creating a simple application in VB where i am reading a single table in SQL Server 2005.

    An easy example of what i am trying to achieve would be the following where a user enters data for the length and width fields and then i need the VB application to multiply the length field x the Width Field to achieve the result for the Answer field.

    Length
    Width
    Answer

    How would i achieve same - Stored procedure ? Also, is the updated answer field only viewable when data application is refreshed etc.

    Any help appreciated

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Why would you need a table to multiply length times width?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Oct 2009
    Posts
    93
    That was just an example. I need to save the entries and answers in a table where the answers are calculated automatically

  4. #4
    Join Date
    Oct 2009
    Posts
    93
    Is it possible?

  5. #5
    Join Date
    Oct 2009
    Posts
    93
    I am using Developer Express Apps to create the application. I could use Unbound columns to create the columns i require with associated calculations but am unsure if i should be using unbound columns or hardcoding the calculations someway in SQL

    Any advice is greatly appreciated

  6. #6
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    try triggers to perform the calculation

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You shouldn't store that calculated data to begin with. You'll have to write code (triggers, etc...) to maintain should any of the parameters change.
    You should calculate those values when the data is retrieved.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    That, or use a computer column.

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by pootle flump View Post
    That, or use a computer column.
    computed column

    Computed Columns

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •