有几张表,里面的字段不同,但每张表都有一个type字段。
现在想在这几张表中插入相同的记录,只是type字段不同。
如: A       B         C         Type
     1       2         3         type1
     3       7         8         type1
     7       8         9         type1
插入后:
     A       B         C         Type
     1       2         3         type1
     3       7         8         type1
     7       8         9         type1
     1       2         3         type2
     3       7         8         type2
     7       8         9         type2
其他几张都是如此,想同过一个循环,一条Sql语句实现所有表的插入。
谢谢!在线等待!

解决方案 »

  1.   

    insert into tablename
    select a,b,c, 'type2' from tablename
      

  2.   

    昏!其他表的字段呢
    我需要一条 sql 语句解决问题
    哥哥
      

  3.   

    可以在一个表上建立触发器,当插入数据时候,给其他表插入同样的但Type值不同的数据。
    create Trigger Tri_table1 on tables
    for insert
    as 
    insert into Table2
    select A,B,C,'Type2' from Inserted
    insert into Table3
    select A,B,C,'Type3' from Inserted
      

  4.   

    1,2楼朋友写的本来就是一句SQL
    2,其它字段,你自己加,你没写出来,别人自然无法写在语句里
    3,要是同时写入多个表,你自己也说了想用循环实现.
      

  5.   

    现在只是想做数据库的数据更新
    你这样每张表做个触发器也不符合我的要求啊
    所有表的字段都不知道,就知道有个type字段
    想简单点快速实现