创建临时表的时候不能添加一个自增列

jol_boy 2007-08-24 10:59:48
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,有什么办法解决吗?
...全文
548 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
LYDF4151 2007-08-24
  • 打赏
  • 举报
回复
首先排除语法及拼写错误后发贴.
zjexe 2007-08-24
  • 打赏
  • 举报
回复
alter table A
drop column 自增列

或者
alter table A
ALTER COLUMN 自增列 int
jol_boy 2007-08-24
  • 打赏
  • 举报
回复
不是的,这个是我写到这里的时候出错,我取数据的那表A里,ID就是个自增列,现在我构建一个临时表的时候也需要一个自增列,因为表A里的数据我不是都需要,所以我得在临时表中增加自增列,怎么去除原先表A中的自增列属性啊
_风中的落叶 2007-08-24
  • 打赏
  • 举报
回复
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

identity(int,1,1)
你括号有错
friendlyFour 2007-08-24
  • 打赏
  • 举报
回复
在创建##ls_jtsjtable的时候可以加啊

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧