在程序中通过一个函数来检测,那个表有一个自增列(ID)做主键,一次加一.

解决方案 »

  1.   

    declare @maxid bigint,@typename varchar(300),@overflow bitselect @typename = s.name from syscolumns c,sysobjects o,systypes s
     where c.id = o.id and o.name = 'table1' and c.name = 'id' 
    and s.xusertype = c.xusertypeselect @maxid = max(id) from table1set @overflow =
    case 
      when (@typename = 'int' and @maxid >= 214748364) then 1
      when (@typename = 'smallint' and @maxid >= 32767) then 1
      when (@typename = 'tinyint' and @maxid >= 255) then 1
      when (@typename = 'bigint' and @maxid >= 9223372036854775807) then 1
      else 0    
    endprint @overflow
    o.name = 'table1'   填你要判断的表名
    c.name = 'id'   填你要判断的列名如果id自长列已经增加到该类型所能表示最大范围,返回1,否则返回0
      

  2.   

    你的程序太伟大了,int类型一般是用不满的,如果实在要用完就用bigint。估计在退休前是没法用完的。
      

  3.   

    要是bigint还不行,就改成decimal,想要多大有多大。
      

  4.   

    呵呵
     junqiang(未结帖数:0) ( ) 信誉:100  2006-06-01 13:07:00  得分: 0  
     
     
       你的程序太伟大了,int类型一般是用不满的,如果实在要用完就用bigint。估计在退休前是没法用完的。