
05以后可以这样写
with temp1(col1) as(select 1 col1
union all
select col1+2 col1
from temp1
where col1+2<=100
)
select sum(col1) from temp1
没测试,有问题你再追问吧,
***************************好吧,忘记素数是什么了,,写成了1,3,5,7这样的和了,,,
select sum(a.number)from master..spt_values a
where a.number between 2 and 100 and a.type='p'
and not exists(select * from master..spt_values b
where b.number between 2 and 100 and b.type='p'
and a.number>b.number
and a.number%b.number=0)
createprocedure
p_1(@参数1
类型,@参数2
类型)
as来定义带参数的存储过程,这样存储过程里面就可以使用你传递过来的参数了。跟平时写但参数的函数是一样的。
然后你调用的时候
exec
p1(参数1,参数2)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)