如何修改一个字段的值等于另一张表的某个字段
2个回答
2017-05-04
展开全部
更新一个表的字段值等于另一个表的字段值
update a
set a.ty2=b.ty1
from t2 a,t1 b
where a.n2=b.n1
更新t2表的ty2字段的值为t1表的ty1字段的值,条件是a表的n2=b表的n1
update a
set a.ty2=b.ty1
from t2 a,t1 b
where a.n2=b.n1
更新t2表的ty2字段的值为t1表的ty1字段的值,条件是a表的n2=b表的n1
展开全部
if OBJECT_ID('students') is not null
drop table students;
go
create table students (student_id char(13) primary key,name varchar(20) not null);
go
if OBJECT_ID('accounts') is not null
drop table accounts;
go
create table accounts (account_id char(13) primary key,passwd binary(20) not null);
go
create trigger trg_students_ins on students
for insert
as
set nocount on;
insert into accounts (account_id, passwd)
select student_id,hashbytes('sha1',student_id) from inserted;
go
insert into students values('S2010F0402001','Wang Fang');
select * from students;
select * from accounts;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |