把表的A字段的默认值 设成B字段 不用触发器能做吗?谢谢

解决方案 »

  1.   

    什么情况下完成??
    update tablename
    set columnname='B'
    呵呵也可以完成。
      

  2.   

    ----生成测试数据表,id列为标识列,用于定位行.
    create table tab (id int IDENTITY,A int,B int)
    GO
    ----创建插入触发器,使新插入行的A列值等于B列值.
    create trigger t on tab for insert
    as
    update tab set A = x.B from tab as x,inserted as i where x.id = i.id
    go
    ----插入测试数据
    insert tab(B) 
    select 9 union all
    select 8 union all
    select 7 union all
    select 6 union all
    select 5 
    ----显示触发器是否成功
    select * from tab 
    ----删除测试对象
    drop trigger t
    drop table tab
      

  3.   

    create table test (
     id int identity(1,1) ,
     b  int ,
     a  default b 
    )
      

  4.   


    create table test (
    id int identity(1,1) ,
    b int ,
    a default b
    )
    ================================
    这个对吗 a default b ???????????
      

  5.   

    create table test (
    id int identity(1,1) ,
    b int ,
    a as b
    )