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
 General SQL Server Forums
 New to SQL Server Programming
 problem in Execute the Procedure

Author  Topic 

teamjai
Yak Posting Veteran

52 Posts

Posted - 2015-05-05 : 02:09:53
The below code i am executing, but the result
Exec c_Fill_BasicData '5D97605A2306B04EBC47317B5E6426BF','648FB08FF45555459C948ECF454FF598',1,0,2.5,0

Code for procedure
ALTER PROCEDURE [dbo].[c_Fill_BasicData]
-- Add the parameters for the stored procedure here
@PCGuid varchar(36),
@ProGUID varchar(36),
@IT decimal(18,2),
@NoOfServices int,
@NoofEach int,
@Height decimal (18,4)
As
Begin
Set NOcount ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
Update #temp Set EachAbs = Each * @NoOfEach.

end

Here the
Each Value = 4
@NoOfEach = 2.5 (passing is decimal , but i am using int)
Result is EachAbs = 8 (4* 2)

expecting Result is EachAbs = 10 (4* 2.5)

what is the wrong inmy code

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2015-05-05 : 02:17:40
then you should declare @NoofEach not as int but as decimal(10,2)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

teamjai
Yak Posting Veteran

52 Posts

Posted - 2015-05-05 : 02:26:52
quote:
Originally posted by khtan

then you should declare @NoofEach not as int but as decimal(10,2)


KH
[spoiler]Time is always against us[/spoiler]




Thank you.

So here SQL consider only int, suppose user pass decimal they coverted to int. i am i right?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2015-05-05 : 02:31:34
yes.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2015-05-05 : 10:01:27
In case relevant note that SQL is not able to CAST a '5D97605A2306B04EBC47317B5E6426BF' into a GUID - the original needs to have the "-" punctuation.

Personally I would not store GUIDs as varCHAR() - wastes too much space!!
Go to Top of Page
   

- Advertisement -