set @sql = N'select no=identity(int,1,1),id,stepCode,lcType,clgclj,zhcl_sj into ##ls_jtsjtable  from ' + @tblName + N' where isEnd=0 and isdelete=0'
exec sp_executesql @sql这里no=identity(int,1,1)是我向要的连续编号的NO,id是原来的表中的自增列,可是提示说已经以后了ID,不可在添加NO,有什么办法解决吗?

解决方案 »

  1.   

    在创建##ls_jtsjtable的时候可以加啊
      

  2.   

    set @sql = N'select no=identity(int,1,1),id,stepCode,lcType,clgclj,zhcl_sj into ##ls_jtsjtable  from ' + @tblName + N' where isEnd=0 and isdelete=0'
    exec sp_executesql @sqlidentity(int,1,1)
    你括号有错
      

  3.   

    不是的,这个是我写到这里的时候出错,我取数据的那表A里,ID就是个自增列,现在我构建一个临时表的时候也需要一个自增列,因为表A里的数据我不是都需要,所以我得在临时表中增加自增列,怎么去除原先表A中的自增列属性啊
      

  4.   

    alter table A
    drop column 自增列或者
    alter table A
    ALTER COLUMN 自增列 int