如题!求解!谢谢!

解决方案 »

  1.   

    ALTER TABLE dbo.tbname ADD
    columnname int NULL DEFAULT 0 
    GO
      

  2.   

    update tbname set columnname=0
      

  3.   

    已有数据是指 之前表中存储的。添加这个列后,该列值为默认值表T
    id name  
    1  wang
    变为
    表T1
    id name age
    1  wang 0
      

  4.   

    alter table aa add 列名 int default  0 
    update aa set 列名=0
      

  5.   

    有没有一句话搞定的啊?
    哈哈 我也想到了你的办法!
    我google到这么一句话alter table table_name add column_name nvarchar(20) default ('') with values 1.with values用于修改已有记录。 但是看不懂!
      

  6.   

    create table tb(id int,col int)
    insert into tb select 1,3 union all select 2,6
    go
    alter table tb add col1 int not null default 0
    go
    select * from tb 
    /*
    id          col         col1
    ----------- ----------- -----------
    1           3           0
    2           6           0(2 行受影响)
    */
    go
    drop table tb
      

  7.   


    嗯 是的!加个not null 确实能搞定!
    嘎嘎!谢谢!