34,590
社区成员
发帖
与我相关
我的任务
分享
ALTER PROCEDURE dbo.proc1
(
@a int,--常量,如2
@x float,--变量X,如1.1
@d float--精度,如0.0001
)
AS
BEGIN
declare @Ret float
declare @left float
declare @temp float
declare @j float
set @j=0.1
set @temp=@a-(@x+log(@x))
declare @count int
while @temp>@d
begin
if @a-((@x+@j)+log(@x+@j)) >@temp or @a-((@x+@j)+log(@x+@j))<0
begin
set @j=@j/10
set @x=@x+@j
end
else
begin
set @x=@x+@j
end
set @temp=@a -(@x+log(@x))
end
select @x
END