select '0'+id as id from tablename

解决方案 »

  1.   

    如果ID是(不合理地)设成数值型的话:select '0'+cast(id as varchar(40)) as id from tablename
      

  2.   

    如果要求宽度一致的话,比如5位:
    select right('0000'+id,5) as id from tablename
      

  3.   

    id是int的话应该是
    select '0'+convert(varchar(10),id) as id from tablename
    varchar的话
    select '0'+id as id from tablename
      

  4.   

    update 表名 set id='0'+id
      

  5.   

    select right('0000'+id,5) as id from tablename屡试不爽