怎么样批量在SQL2005插入数据
一张表A 里面有很多条数据,要插入到A1表中。表A和表A1的字段相同
表A是文本类型导入进去的,只有一个字段
要把A表中的数据全部插入到A1中,因为用到了一些触发器,所以只能一条一条插入,相当于,插入一条 执行一次触发器。 有什么好的方法 批量插入‘
[解决办法]
触发器也可以批量插入啊
insert 表名
select col1,col2,col3 from inserted...
这样就可以的
insert into A1
select * from A
@v_description = SubString(dic,109,50) from inserted
select @v_createtime,@v_userid,@v_identify,@v_pageurl,@v_usertoken,@v_sourcefilename,@v_stamp,@v_stbid,@v_fee,@v_description
if exists(select *from inserted where dic like '%auth_info%') --用户基本表
begin
insert into UserBase(userid,stamp,identify,stbid,usertoken,createtime,other)values(@v_userid,@v_stamp,@v_identify,@v_stbid,@v_usertoken,@v_createtime,'');
end
if exists(select *from inserted where subString(dic,82,4)='play' )--播放表
begin
insert into UserPlaySongData(userid,stamp,identify,sourcefilename,createtime,other)values(@v_userid,@v_stamp,@v_identify,@v_sourcefilename,@v_createtime,'');
end
if exists(select *from inserted ) --用户日志表
begin
insert into UserLog(userid,pageurl,identify,stamp,createtime,other)values(@v_userid,@v_pageurl,@v_identify,@v_stamp,@v_createtime,'');
end
if exists(select *from inserted where dic like '%cost%')--计费表
begin
insert into UserCharge(userid,identify,stamp,fee,description,createtime,other)values(@v_userid,@v_identify,@v_stamp,@v_fee,@v_description,@v_createtime,'');
end
end