我想通过使用sessionid和profileid验证表profilelogs和profilelogs_arch之间的数据来创建存储过程。如果会话ID和profileid不同,那么应该继续将数据插入profilelog_arch,否则插入不是
答案 0 :(得分:0)
Create prcedure sp_archiveprofile_logs
as
IF EXISTS ( SELECT PROFILEID,SESSIONID FROM tbl_profilelogs as main exists
(SELECT PROFILEID,SESSIONID FROM tbl_profilelogs_arch as arch where arch.profileid<>main.profileid and arch.sessionid<>main.sessionid))
begin
insert into tbl_profilelogs_arch select * from tbl_profilelogs
end
以上代码只是一个逻辑,请根据要求进行必要的更改。
谢谢
答案 1 :(得分:0)
创建prhedure sp_archiveprofile_logs
作为
插入tbl_profilelogs_arch select * from tbl_profilelogs
端
答案 2 :(得分:0)
Create prcedure sp_archiveprofile_logs
as
IF EXISTS ( SELECT 1
FROM tbl_profilelogs as main exists
(SELECT 1
FROM tbl_profilelogs_arch as arch
WHERE arch.profileid<>main.profileid
AND arch.sessionid<>main.sessionid
)
)
BEGIN
INSERT INTO tbl_profilelogs_arch select * from tbl_profilelogs
END
试试吧......