July 10, 2008 at 2:34 pm
Hi can someone help me to write a stored proc to add the 3 subjects and get their totals
July 10, 2008 at 2:55 pm
create proc procname
@subject1 int,
@subject2 int,
@subject3 int,
@result int output
as
set @result = @subject1+@subject2+@subject3
Is this want you want?
I think this sproc will allow you to enter values for three subjects and then lets you add those values.
July 10, 2008 at 3:15 pm
Here is a link to an article that was created to help new folks formulate posts that will get them the help they want. The information you've given so far is no where near enough to tell what you are trying to do. Please read the article and post your question with more detail so that we can help you.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
July 10, 2008 at 5:04 pm
but when i excuted i got this below err msg,
Msg 201, Level 16, State 4, Procedure procname, Line 0
Procedure or function 'procname' expects parameter '@result', which was not supplied.
@result should be displayed as o/p. why asking for a parameter to be supplied?
please help as i new and struggling to learn sql server programming
July 11, 2008 at 8:49 am
You don't need the quotes in the execute command. The parameters are integers, not strings.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 11, 2008 at 11:17 am
Thanks much it worked and if i want to extend the pgm to calculate the percentage and give them the grade like A,B, C..
Then how do i write?
i appreciate your help
July 12, 2008 at 2:47 pm
change this
create proc procname
@subject1 int,
@subject2 int,
@subject3 int,
@result int output
as
set @result = @subject1+@subject2+@subject3
to this
create proc procname
@subject1 int,
@subject2 int,
@subject3 int,
as
declare @result int
set @result = @subject1+@subject2+@subject3
it will only expect 3 parameters then
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
July 13, 2008 at 8:54 pm
Thanks for your inputs.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply