Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6211501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:20:54+00:00 2026-05-24T06:20:54+00:00

Hey so I have a stored procedure populating a gridview and in my stored

  • 0

Hey so I have a stored procedure populating a gridview

and in my stored procedure I have two columns such as

Total_Price DataType Money

and

Discount DateType decimal(18, 0)

and I want to display a derived column called Actual Price which is

Total_Price - Discount

is it best to create this column in the stored procedure or calculate on load in the gridview ?

Heres my stored procedure at the moment

    SELECT     f.supplier_name,d.product_ID_key, d.product_name AS productName, d.packsize, d.tradePrice, d.IPU_code, d.EAN_code, c.discount, e.stock_indicator
FROM         aw_customer AS a INNER JOIN
                      aw_cust_contract AS b ON a.cust_ID_key = b.cust_ID_key INNER JOIN
                      aw_contract_line AS c ON b.contract_ID_key = c.contract_ID_key INNER JOIN
                      aw_product AS d ON c.product_ID_key = d.product_ID_key INNER JOIN
                      aw_stock AS e ON d.product_ID_key = e.product_ID_key INNER JOIN
                      aw_supplier AS f ON d.supplier_ID_key = f.supplier_ID_key
WHERE     (a.cust_ID_key = @customerId)
ORDER BY d.product_name
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:20:54+00:00Added an answer on May 24, 2026 at 6:20 am

    I would calculate this at Stored Procedure level, so that any calls to this Stored Procedure would return the same results (you haven’t got to do the math on other gridviews etc in the future if they are calling the same Stored Procedure)

    In situations like this, I’ve often created a SQL View so that the calculations are done within the view, and then multiple Stored Procedures can call this View and display the data like:

    SELECT Total_Price
           ,Discount
           ,Actual_Price
    FROM [v_TableA]
    

    http://msdn.microsoft.com/en-us/library/aa214068%28v=sql.80%29.aspx

    See this article for details of Indexing Views, which will also improve performance:

    http://technet.microsoft.com/en-us/library/cc917715.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, i have created a stored procedure, wherein i have datetime field in
Hey guys, I have a stored procedure that outputs just the column of a
Hey all, I have a stored procedure and I need to call it within
Hey I have a problem comparing the value of a CGPoint (struct with two
Hey all this is the first time i am calling a stored procedure via
Hey guys, I have a GridView which is binded to SqlDataSource, everything works fine,
I have a stored procedure that is receiving as a parameter a list of
Hey guys, I'm working on a stored procedure, but I'm stuck on how to
Hey I have a gridView and I would like to extract the PhotoPath (ftppath
Hey I would like to display certain data with my stored procedure for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.