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)
 float problem

Author  Topic 

chih
Posting Yak Master

154 Posts

Posted - 2008-04-10 : 22:25:26
Hi Everyone,

here is a simple SP

Create procedure test
@input float
as
Begin
return @input
ENd

If I execute the following
declare @output float
exec @output=test 1.12121
select @output

why I got 1 not 1.12121?

any idea? How to get the correct result?

Thank you in advance

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-10 : 22:40:48
Because RETURN only returns integers. You must use an output variable instead.

Create procedure test
(@input float, @output float OUTPUT)
as
Begin
SET @output = @input
ENd
go

declare @output float
exec test @input = 1.12121, @output = @output OUTPUT
select @output

drop proc test

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

chih
Posting Yak Master

154 Posts

Posted - 2008-04-11 : 02:24:04
Thank you

quote:
Originally posted by tkizer

Because RETURN only returns integers. You must use an output variable instead.

Create procedure test
(@input float, @output float OUTPUT)
as
Begin
SET @output = @input
ENd
go

declare @output float
exec test @input = 1.12121, @output = @output OUTPUT
select @output

drop proc test

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Go to Top of Page
   

- Advertisement -