同一个表中复制数据问题!!!

no1abc 2003-01-14 02:21:28
在同一表中如何把原有的所有数据再追加到表中同时更改其中的一个字段值?表的关键字段ID是自动增加方式!急
...全文
39 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
SpringField 2003-01-29
  • 打赏
  • 举报
回复
mark
happydreamer 2003-01-14
  • 打赏
  • 举报
回复
insert时 column是要列举出来的
建议还是保留id自动增长
alexwoowf 2003-01-14
  • 打赏
  • 举报
回复
set identity_insert oldtab on
select col1,col2,col3 into newtab from oldtab
set identity_insert oldtab off
no1abc 2003-01-14
  • 打赏
  • 举报
回复
关键字一定要关掉吗!
还有再置回来,会不会把记录顺序搅乱了!
有具体点的做法吗?谢谢
yelook 2003-01-14
  • 打赏
  • 举报
回复
当然了,不过你列出的字段和后面记录集的字段要一一对应

必要时候还可以通过
set identity_insert on
把自动增长关掉
--insert
过后再置回来
set identity_insert off
kevinhit 2003-01-14
  • 打赏
  • 举报
回复
好像是select * into where 这样的语句
no1abc 2003-01-14
  • 打赏
  • 举报
回复
我表的字段很多!可以不必列出所有的字段吗?
hjhing 2003-01-14
  • 打赏
  • 举报
回复
insert into yourTable
select f1,f2,f3,'changed',f5 from yourTable

---- 假如你的表為(f0 identity(int,1,1),f1 int ,f2 int,f3 int ,f4 varchar(10),f5 char(10))
jspandpb 2003-01-14
  • 打赏
  • 举报
回复
你是需要在程序里控制
还是直接在sqlserver里进行操作

34,590

社区成员

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

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