建立完后调用这个函数将1到10 的累积显示出来。
------解决方案--------------------
create function f_sum(@N int)
returns int
as
begin
return ([email protected])[email protected]/2
end
go
select dbo.f_sum(10)
go
drop function f_sum
go
------解决方案--------------------
create function fun_j(@num int)
returns int
as
begin
declare @a int
declare @b int
set @a=1
set @b=1
while @a <[email protected]
begin
set @[email protected][email protected]
set @[email protected]+1
end
return @b
end
select dbo.fun_j(5)
---
120