前台搞一个函数,
然后直接insert

解决方案 »

  1.   

    写个触发器的---测试数据---
    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb]([col1] int,[col2] varchar(10))
    insert [tb]
    select 1,'a' union all
    select 2,'b' union all
    select 3,'c' union all
    select 4,'d'
     
    --建触发器
    create trigger tri_ins
    on tb
    for insert
    as
      update tb
      set col2=isnull(i.col2,'')+';312; '
      from inserted i
      where tb.col1=i.col1 and isnull(tb.col2,'')=isnull(i.col2,'')--插入新数据
    insert tb(col1) select 5
    insert tb(col1,col2) select 6,'abc'--查询
    select * from [tb]/**
    col1        col2       
    ----------- ---------- 
    1           a
    2           b
    3           c
    4           d
    5           ;312; 
    6           abc;312; (所影响的行数为 6 行)
    **/