如下代码中为修改bcp数据库中表B_TaskFileMonitor中的列FileSizeOriginal的类型为bigint

 

use bcp;
DECLARE  @dataTypeName nvarchar(102);
--判断是否存在这一列
IF COL_LENGTH('B_TaskFileMonitor', 'FileSizeOriginal') IS not NULL
    begin
        --查出字段的类型
        select @dataTypeName=t.name from sysobjects o,syscolumns c,systypes t
                where o.id=c.id and c.xtype=t.xtype
                and o.name='B_TaskFileMonitor' and c.name='FileSizeOriginal';
        --如果字段不是bigint,那么将其转化为bigint
        if(@dataTypeName<>'bigint') alter table [BCP].[dbo].[B_TaskFileMonitor] alter column [FileSizeOriginal] bigint;
    end

 

相关文章:

  • 2022-02-05
  • 2021-06-11
  • 2022-02-16
  • 2021-11-30
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案