有一个表有1000多条记录,结构如下:
table: x,y,z
存储过程要实现,z=y/x/2(其中如果x=0,那么z=0;如果x>0,那么z=y/x/2)
table: x,y,z
存储过程要实现,z=y/x/2(其中如果x=0,那么z=0;如果x>0,那么z=y/x/2)
解决方案 »
- 手动在数据库里添加数据不行 出现以下情况。
- 如何查看执行存储过程的执行计划?
- sql server2005如何用语句修改登陆用户的用户映射?
- 用户 '' 登录失败。该用户与可信 SQL Server 连接无关联。
- 疑问。。大家帮忙看看
- 统计手机号码出现次数以及排列
- 客户端连接服务器SQL server2000的实例时 提示 连接后报错“server-sql server不存在或拒绝ConnectionOpen(Connect())”(只有一台电脑存在这个问题,其他电脑使用正常)
- 在恢复数据库(bak文件)时出错?
- 请问如何得到当前连接的spid对应的ip地址?多谢
- 各位大侠,请问以下查询能不能用一句SQL实现?只有30分,全给了
- 我该如何设计这个数据库
- 我想找一个能在XP上安装的SQL2000!谁能告诉我!
as
update tb set z=0 where x=0
update tb set z=(y+0.0)/x/2 where x<>0
go
as
begin
uppdate tablename
set z=(case when x=0 then 0
when x>0 then y/x/2
end
) end
if exists (select name from sysobjects
where name='count'and type='p')
drop procedure count
go
use [数据库名]
go
CREATE procedure count
update table set z=0 where x=0
update table set z=x/y/2 where x>0
go
as
begin
uppdate tablename
set z=(case when x=0 then 0
when x>0 then y/x/2
else z
end
) end
2、update两次。
为什么不用游标遍历,一条一条的处理。连循环都不用加SQL自动遍历记录了????