a表和b表合并,结果留在a表,清空b表.

cilyboy 2006-02-14 10:14:41
a表和b表合并,当然a,b表已经对比过一次了,不会重复,现在需要把b表的内容合并到a表中,b表清空掉.
求简单的存储过程.
...全文
228 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
标示列是不能通过程序进行插入数值的,你只需要插入其他的字段就行了。
$扫地僧$ 2006-02-14
  • 打赏
  • 举报
回复
Create Proc SP_Test
as
begin
insert into A表 select phone,name from B表
truncate table B表
End
$扫地僧$ 2006-02-14
  • 打赏
  • 举报
回复
你不要id就可以了啊!
try:
insert into taotao1(phone,name)
cilyboy 2006-02-14
  • 打赏
  • 举报
回复
--存储过程

Create Proc SP_Test
as
begin
insert into A表(字段....)
select 字段 ...from B表

truncate table B表
End
-----------------
两个表都由一个id自增的字段
insert into taotao1(id,phone,name)

服务器: 消息 544,级别 16,状态 1,过程 SP_Test,行 4
当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'taotao1' 中的标识列插入显式值。
这个咋整啊
sunyong790903 2006-02-14
  • 打赏
  • 举报
回复
create procedure hebing
as
if exists(select 1 from sysobjects where id=object_id('b') and xtype='u')
begin
insert into a select * from b
truncate table b
end
sunyong790903 2006-02-14
  • 打赏
  • 举报
回复
create procedure hebing
as
if exists(select 1 from sysobjects where id=object_id('b') and xtype='u')
begin
insert into a select * from b
trun table b
end

-狙击手- 2006-02-14
  • 打赏
  • 举报
回复
create procedure hebing
as
begin
insert into a select * from b
truncate table b
end
samson_www 2006-02-14
  • 打赏
  • 举报
回复
create procedure hebing
as
begin
insert into a select * from b
delete b
end
wgsasd311 2006-02-14
  • 打赏
  • 举报
回复
create proc p
as
if exists(select 1 from sysobjects where id=object_id('b') and xtype='u')
begin
insert into a select * from b
drop table b
end
go
zlp321002 2006-02-14
  • 打赏
  • 举报
回复
--存储过程

Create Proc SP_Test
as
begin
insert into A表(字段....)
select 字段 ...from B表

truncate table B表
End
子陌红尘 2006-02-14
  • 打赏
  • 举报
回复
--把b表的内容合并到a表中
insert into a select * from b

--清空b表
truncate table b
zlp321002 2006-02-14
  • 打赏
  • 举报
回复
insert into A表(字段....)
select 字段 ...from B表

truncate table B表
cilyboy 2006-02-14
  • 打赏
  • 举报
回复
a表和b表字段一样,合并后字段都不能改

34,590

社区成员

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

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