CREATE TRIGGER TABLEA_Update
ON TABLEA
AFTER UPDATE
AS
BEGIN
IF UPDATE(用户名)begin Update TABLEB
Set 用户名=Inserted.用户名
From TABLEB,Deleted,Inserted --Deleted和Inserted时系统临时表
Where TABLEB.用户名=Deleted.用户名
end
IF UPDATE(密码)begin Update TABLEB
Set 密码=Inserted.密码
From TABLEB,Deleted,Inserted
Where TABLEB.密码=Deleted.密码
end
SET NOCOUNT ON;
END
GO
ON TABLEA
AFTER UPDATE
AS
BEGIN
IF UPDATE(用户名)begin Update TABLEB
Set 用户名=Inserted.用户名
From TABLEB,Deleted,Inserted --Deleted和Inserted时系统临时表
Where TABLEB.用户名=Deleted.用户名
end
IF UPDATE(密码)begin Update TABLEB
Set 密码=Inserted.密码
From TABLEB,Deleted,Inserted
Where TABLEB.密码=Deleted.密码
end
SET NOCOUNT ON;
END
GO
解决方案 »
- VS2005中的ASP如何实现Dropdownlist和listbox的三级联动
- 急~~~vs2005下调试无法查看页面,只能在iis下浏览页面!
- 又是ASP.NET创建工程时出的问题 500 error
- <%# 为什么javascript在传值的时候c:\inetpub\wwwroot\Gogo\Images会变成c:inetpubwwwrootGogoImages 谢谢
- 用什么控件来做网页中的容器呢
- DataGrid控件中有几个模板列,每个模板列中有一个文本框控件,如果实现其中一个文本框获取焦点,让当前行的背景色变色.谢谢~
- 立即结帐!!用户注稍功能是如何实现的??
- ★★★★★★数据 早绑定问题 ★★★★★★
- 因为状态栏没有显示?
- 我的ASP.NET程序放到其它机器上为什么出现这种错误
- 网页全屏问题
- .net2005的问题
建立一个存储过程,在存储过程中使用事务,大致的sql如下:
create procedute UpdateAAndB
as
declare @errorCode int
select @errorCode=@@error
begin transaction
if @errorCode=0
begin
update 表A
set name=新用户名, password=新密码
where id=用户id
select @errorCode=@@error
end
if @errorCode=0
begin
update 表B
set name=新用户名, password=新密码
where id=用户id
select @errorCode=@@error
end
if @errorCode=0
commit transaction
else
rollback transaction2.最佳解决办法是重构你的数据库设计:专门建立一张用户表用来存放用户名和密码,A表和B表引用这张用户表,这样用户名和密码更新的时候只要更新用户表就行了。接分!