有两个表table1 table2
table1 结构如下 table2结构如下
f1 f2 F1 F2 F3
a 1 a 0 d
b 2 b 0 f
c 3 c 0 s
我是要这样处理的:
table1先处理完成后,然后根据table1的f2字段一次性更新table2的F2字段
使得table2的结构如下
F1 F2 F3
a 1 d
b 2 f
c 3 s
其中f1是主键
请问这样存储过程要怎么写
table1 结构如下 table2结构如下
f1 f2 F1 F2 F3
a 1 a 0 d
b 2 b 0 f
c 3 c 0 s
我是要这样处理的:
table1先处理完成后,然后根据table1的f2字段一次性更新table2的F2字段
使得table2的结构如下
F1 F2 F3
a 1 d
b 2 f
c 3 s
其中f1是主键
请问这样存储过程要怎么写
@f2 char(?)
As
update set table2.f2=table1.F2
from table1 left join table2 on table1.f1=table2.F1 order by f1
where table1.f1=@f2
go
where f1 in (select f1 from talble1)
from table2 left join table1 on table2.f1=table1.F1