--transact-sql编程球50~100之间所有能被3整除的奇数之和
declare @count int,@sum int
select @count=51,@sum=0
while @count<100
begin
if CEILING(@count/3.0)<=FLOOR(@count/3.0)
begin
set @[email protected][email protected]
end
set @[email protected]+2
end
print ‘50到100之间的所有能被3正处的技术之和为‘+cast(@sum as nchar(12))
--transact-sql编程求圆的面积
declare @r float,@area float,@cicrle float
set @r=5.0
set @area=pi()*@r*@r
set @cicrle=2*PI()*@r
print @area print @cicrle
--transact-sql编程实现求一元二次方程的解
declare @a int, @b int,@c int,@x float,@x1 float,@x2 float
select @a=4,@b=7,@c=2
set @x=([email protected])/(2*@a)
set @x1=([email protected]+SQRT(@b*@b-4*@a*@c))/2*@a
set @x2=([email protected](@b*@b-4*@a*@c))/2*@a
if @b*@b-(4*@a*@c)<0
print ‘此一元二次方程无解‘
if @b*@b-(4*@a*@c)=0
print ‘此一元二次方程有唯一的解为:‘+cast(@x as char(8))
if @b*@b-(4*@a*@c)>0
print ‘此一元二次方程有两个解分别为:x1=‘+cast(@x1 as char(8))+‘,x2=‘+cast(@x2 as char(8))