现在数据库中有一个字段是公式计算字段,公式为:(round(([L9] + [L10]),2))
如果现在像把公式删除,但里面的数据想保留,不知道有什么好的方法呢。

解决方案 »

  1.   

    删除公司 ,然后 直接 update更新上去不就可以了么。
      

  2.   

    另加一个字段,将计算结果update 进去。然后删除这个原来的公式字段即可。
      

  3.   

    an example,create table gs(a int,b int,c as a+b)insert into gs(a,b)
    select 1,2 union all
    select 3,5select * from gs/*
    a           b           c
    ----------- ----------- -----------
    1           2           3
    3           5           8(2 row(s) affected)
    */--备份数据
    select * into #gs from gs--删除公式
    drop table gs
    create table gs(a int,b int,c int)--导入数据
    insert into gs(a,b,c)
    select * from #gs--结果
    select * from gs/*
    a           b           c
    ----------- ----------- -----------
    1           2           3
    3           5           8(2 row(s) affected)
    */
      

  4.   

    方法2,create table gs(a int,b int,c as a+b)insert into gs(a,b)
    select 1,2 union all
    select 3,5select * from gs/*
    a           b           c
    ----------- ----------- -----------
    1           2           3
    3           5           8(2 row(s) affected)
    */
    alter table gs add c2 intupdate gs set c2=calter table gs drop column csp_rename 'gs.c2','c','column'--结果
    select * from gs/*
    a           b           c
    ----------- ----------- -----------
    1           2           3
    3           5           8(2 row(s) affected)
    */