Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem with Stored Procedure

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2008-07-22 : 06:00:03
ALTER procedure [dbo].[Akadmix_InsertStudentMarks]
@Marks int,@EDID int,@STUDID int,@OUT varchar(500) out
as
declare @Mx int,@Mn int,@Er int,@Mp float
begin
select @Mx = MaxMarks,@Mn = MinMarks from Tbl_RelationExaminationDetails where ExaminationDetailID = @EDID
if (@Marks>@Mx)
begin
set @OUT = 'You cannot give more than'+@Mx
end
else
begin
if (@Marks < 0)
begin
set @OUT = 'Please Enter A Valid Value'
end
else
begin
if (@Marks < @Mn)
begin
set @Er = 0
end
else
begin
set @Er = 1
end
set @Mp = (@Marks/@Mx)*100

here though i am getting @Marks value as 18 and @Mx value as 50, i am getting 0 to @Mp. why?
please help me on this

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

ayamas
Aged Yak Warrior

552 Posts

Posted - 2008-07-22 : 06:09:01
I think maybe because your datatypes are int.You please see the resultset of this this examples you will understand better.

declare @Marks int
set @Marks=90
select @marks/100
select @marks/100.0
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-22 : 06:53:04
thats because of implicit conversion. try like this:-
set @Mp = (@Marks*100.0/@Mx)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-22 : 07:14:05
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -