473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Variable Math in Stored Procedure

76
Okay here's what I'm trying to accomplish. I'm trying to create a stored procedure to make my life simple when it comes to a form I'm creating. One of the fields in it however is a calculation based on another form it's really simple.

I have the field, stampAvg, which is based on the current maximum of another column. The function to create the new stampAvg is as follows

SELECT MAX(stmScore)*1.25 AS stampAvg FROM tblStamp

That's it.

Now enter my stored procedure...

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE spSetStamp
  2. @name varchar(50)
  3. @score float
  4. @stamp float
  5. AS
  6. SET @stamp AS EXECUTE (SELECT MAX(stmScore)*1.25 AS stampAvg FROM tblStamp)
  7.  INSERT INTO tblStamp (stmName,stmScore,stmStamp)
  8.  VALUES(@name,@score,@stamp)
  9. GO
  10.  
However I'm quite certain that

SET @stamp AS EXECUTE (SELECT MAX(stmScore)*1.25 AS stampAvg FROM tblStamp)

Is incorrect
Aug 24 '06 #1
1 5684
Just a thought wouldn't you be better off using a function?
Aug 25 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rob | last post by:
Please recommend best practice for adding a global variable to an ASP.net class that will take on a Request.Params("") value from the URL calling the aspx page to be used throughout in stored...
4
by: Greg | last post by:
I need to send the result of a procedure to an update statement. Basically updating the column of one table with the result of a query in a stored procedure. It only returns one value, if it didnt...
2
by: Chip Mayan | last post by:
Hello, I am fairly new at stored procedures. I have created some that will go through a table and return a start date and an end date that is dependent upon the fiscal period you want, but I...
1
by: Rob Wire | last post by:
Please let me know the preferred way to do the following. Accept a Variable in the calling page's URL of an ID. Set that variable to be global scope of the class so that it can be used throughout...
5
by: Andy G | last post by:
I have a registration page that captures 75% of the users data. After they enter that info they are redirected to one of two pages depending on how they answered a question on the registation...
4
by: Rob | last post by:
Using VB.net and SQL server... I have a stored procedure that is simply returning a row count.... I know how to execute a stored procedure and add the output parameter. But how do I store...
9
by: anilcool | last post by:
Hi all, Another novice question. I want to insert multiple records into my DB2 database using stored procedure but I do not know how many I would like to insert at any given time. Each record...
3
by: DR | last post by:
I heard there is some trick to referencing statics in C# CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a little...
3
by: dmorand | last post by:
I'm very new to stored procedures so this is probably something very dumb. I want to pass a name of a table to be created to my stored procedure. I'm using the variable @tableName in the code below...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.