现有3张表,表1 t_BOS200000062Entry2,表2 t_Item_3020,表3 t_BOS200000062Entry3,根据t_BOS200000062Entry2表的FText查询t_Item_3020 表,并将查询结果FNumber数据插入t_BOS200000062Entry3表的FBase1 字段中了,请教如何实现代码如下
create TRIGGER [t_BOS200000062Entry3] 
   ON  [dbo].[t_BOS200000062Entry3]
   FOR INSERT, UPDATE
AS 
begin 
if exists ( SELECT t_Item_3020.FNumber FROM  t_BOS200000062Entry2 inner JOIN
t_Item_3020 ON t_BOS200000062Entry2.FText = t_Item_3020.FName)
INSERT INTO  t_BOS200000062Entry3 FBase1 ON t_BOS200000062Entry2.FText = t_Item_3020.FName
End

解决方案 »

  1.   

    用不到触发器吧insert into t_BOS200000062Entry3(FBase1) select FNumber from (select FNumber from t_Item_3020 inner join t_BOS200000062Entry2 on  t_Item_3020.FText = t_BOS200000062Entry2.FText) A
      

  2.   

    用不到触发器吧insert into t_BOS200000062Entry3(FBase1) select FNumber from (select FNumber from t_Item_3020 inner join t_BOS200000062Entry2 on  t_Item_3020.FText = t_BOS200000062Entry2.FText) A
      

  3.   

    你用触发器,怎么不用到Inserted和Deleted中取数据呢,那还用触发器干嘛?