请问在存储过程中能不能用“insert into temp1 select * from temp2"语句?

Gorgee 2002-12-22 11:51:30
各位高手:
我在一存储过程中想将一表中的数据导入到另外表中,写入“insert into temp1 select * from temp2"后无法保存,老是提示此句出错!但单独执行就可以,怎么回事啊!
...全文
78 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2002-12-22
  • 打赏
  • 举报
回复
SET IDENTITY_INSERT temp1 ON
insert temp1 (列1,列2) select 列1,列2 from temp2
ben988211 2002-12-22
  • 打赏
  • 举报
回复
看看子段是否对应

上面的语句都没错
Gorgee 2002-12-22
  • 打赏
  • 举报
回复
返回错误信息:
incorrect syntax near the keyword 'insert'
Gorgee 2002-12-22
  • 打赏
  • 举报
回复
还是不行……
恳请高手再帮我想想如何解决?
tollers 2002-12-22
  • 打赏
  • 举报
回复
我试过了,没错啊
你那提示了什么?
pengdali 2002-12-22
  • 打赏
  • 举报
回复
insert temp1 (列1,列2) select 列1,列2 from temp2
pengdali 2002-12-22
  • 打赏
  • 举报
回复
试试:
insert 库名..temp1 select * from 库名..temp2
hbwhwanghua 2002-12-22
  • 打赏
  • 举报
回复
除了楼上几位说的外,
用insert into temp1 select * from temp2
你得保证temp1表已经存在,否则要用select * into temp1 from temp2
如果还不行的话,估计你的数据库出问题了,
pengdali 2002-12-22
  • 打赏
  • 举报
回复
SET IDENTITY_INSERT temp1 ON
insert temp1 (列1,列2) select 列1,列2 from temp2
set identity_insert temp1 off

22,294

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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