zoukankan      html  css  js  c++  java
  • 怎样将数据库中所有表中含有numeric(18,2)字段改成numeric(18,10)及将float改成numeric

    怎样将数据库中所有表中含有numeric(18,2)字段改成numeric(18,10)
    declare
    c cursorforselect'alter table ['+ a.name +'] alter column ['+b.name+'] numeric(18,10);'from sysobjects a,syscolumns b,systypes c where a.id=b.id and b.xtype=c.xtype and a.type='u' and b.xprec=18 and b.xscale=2 and c.name in('decimal','numeric') open c declare@cvarchar(8000) fetchnextfrom c into@cwhile(@@fetch_status=0) beginexec(@c) fetchnextfrom c into@cendclose c deallocate c


    将float改成numeric
    declare c cursor
    for
        select 'alter table ['+ a.name + '] alter column ['+b.name+'] numeric(18,2);'
        from sysobjects a,syscolumns b,systypes c
        where a.id=b.id
          and b.xtype=c.xtype
          and a.type='u'
          and b.xtype=62
          and c.name in('float')
    open c
    declare @c varchar(8000)
    fetch next from c into @c
    while(@@fetch_status=0)
        begin
            exec(@c)
            fetch next from c into @c
        end
    close c
    deallocate c
  • 相关阅读:
    Springmvc
    Mybatis关联关系
    Mybatis整合ehcache 和 redis
    Mybatis与spring集成
    MyBatis动态sql和分页
    MyBatis入门
    Vue模板语法(二)
    Vue模板语法(一)
    Spring---SSH整合(二)
    Spring---SSH整合
  • 原文地址:https://www.cnblogs.com/oer2001/p/2729577.html
Copyright © 2011-2022 走看看