解决方案 »

  1.   

    用触发器,当表A  id字段新增数据 触发  更新到表B id 字段
      

  2.   


    drop table t 
    create table t(
    id int identity ,
    name varchar(30)
    )
    set nocount on
    insert into t(name) values(100) 
    select @@IDENTITY
    insert into t(name) values(100) 
    select @@IDENTITY
    set nocount off
    ---------------------------------------
    1
    ---------------------------------------
    2string strsql = "insert into t(name) values(100) ";
    strsql += "select @@IDENTITY"; 
    cmd.CommandText = strsql ;
    object obj = myComm.ExecuteScalar();
      

  3.   

    create trigger 触发器名
    on 表A
    after insert
    as
    begin
    insert into表2(id)
    select ID from inserted 
    end
    要注意 你表2 id 字段不能为自增列
      

  4.   

    insert into a ([user],pass) values('aaa','bbb');
    insert into b (id) values (@@IDENTITY)
      

  5.   

    这些建议直接用c#调proc传参数。
    写入的判断由proc来做。比较容易实现。