create function f_sqrt(@i float,@t float) returns float as begin while @t>0 select @i=sqrt(@i),@t=@t-1 return(@i) end godeclare @i int,@t int select @i=2,@t=4select dbo.f_sqrt(16,2)drop function f_sqrt----------------------------------------------------- 2.0(所影响的行数为 1 行)
declare @N intset @NUM=16
set @N=4select Power(@NUM,(1.0/@N))/*
------------
2.0000000000
*/
create function f_sqrt(@i float,@t float)
returns float
as
begin
while @t>0
select @i=sqrt(@i),@t=@t-1
return(@i)
end
godeclare @i int,@t int
select @i=2,@t=4select dbo.f_sqrt(16,2)drop function f_sqrt-----------------------------------------------------
2.0(所影响的行数为 1 行)