日期:2014-05-17  浏览次数:20603 次

文本导入数据库后 用insert into 方式 无法触发触发器 怎么解决
create  trigger tr_userLog_insert 
on A1 FOR INSERT
as
   begin   
   declare
           @v_userid int,--用户Id
           @v_stamp int,--邮戳
           @v_identify nvarchar(4),--标识(page,base,play,cost)
           @v_pageurl nvarchar(120),--页面url
           @v_usertoken nvarchar(32),--用户标识
           @v_accesstime datetime,--访问时间
           @v_sourcefilename nvarchar(32),--视频原文件
           @v_stbid nvarchar(24),--机顶盒id
           @v_fee nvarchar(32),--计费代码
           @v_orderdesc nvarchar(50);

    select @v_accesstime = convert(datetime,subString(dic,7,19),120),--accesstime
           @v_userid =  subString(dic,40,9),--userid
           @v_identify = subString(dic,82,4),--identify
           @v_pageurl = subString(dic,88,120),--pageurl
           @v_usertoken = subString(dic,167,32),--usertoken
           @v_sourcefilename = subString(dic,88,9),--sourcefilename
           @v_stamp = SubString(dic,73,7),--stamp
           @v_stbid = subString(dic,132,24),--stbid
           @v_fee = subString(dic,88,10), --fee
           @v_orderdesc  =  SubString(dic,109,50) from inserted 

select @v_userid 用户ID,@v_identify 表标识,@v_stamp 区域代码,@v_pageurl 页面地址,@v_accesstime 访问时间;

    if exists(select *from  inserted  where  dic like '%auth_info%')  --用户基本表
begin
insert into UserBase(userid,stamp,identify,stbid,usertoken,pageurl,accesstime,other)values(@v_userid,@v_stamp,@v_identify,@v_stbid,@v_usertoken,@v_pageurl,@v_accesstime,'');
end
    if exists(select *from inserted  where  subString(dic,82,4)='play' )--播放表
        begin        
insert into UserPlaySongData(userid,stamp,identify,sourcefilename,pageurl,accesstime,other)values(@v_userid,@v_stamp,@v_identify,@v_sourcefilename,@v_pageurl,@v_accesstime,'');
        end    
    if exists(select *from inserted  ) --用户日志表
        begin           
insert into UserLog(userid,pageurl,identify,stamp,accesstime,other)values(@v_userid,@