首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

多表批改

2012-08-08 
多表修改有如下三个表:表A:AID,Name,表B:BID,Age,表C:CID,class ,我想通过一个存储过修改表A中Name字段,表

多表修改
有如下三个表:表A:AID,Name,表B:BID,Age,表C:CID,class ,我想通过一个存储过修改表A中Name字段,表B中的Age字段,表C中的Class字段,请问语句该怎么写?

[解决办法]
何必要存储过程?
update a set name=...
update b set age=...
update c set class=...
[解决办法]

SQL code
create procedure pr_test (    @Name    varchar(8),    @Age    tinyint,    @class    varchar(8))as begin    begin tran     begin try        update A set Name = @Name where ...        update B set Age = @Age where ...        update C set class = @class where ...        commit tran    end try    begin catch        rollback tran    end catch    end 

热点排行