IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_login_log]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_login_log]
GO
CREATE proc [dbo].[mps_login_log]
  @ip varchar(100),@device varchar(30),@cuid varchar(50),@cmpid int,@site nvarchar(200)
  as 
  begin
     set nocount on
 declare @addr varchar(200),@cutype int,@cucallname varchar(200),@cuobjid bigint;
 ---查询登录者信息
 select @cutype=cu_type,@cucallname=cu_callname,@cuobjid=cu_objid from mps_login
 where cu_id = @cuid
 ---插入登录记录表
     insert into mps_loginlog(lg_cuid,lg_ip,lg_device,lg_site,lg_time,lg_cmpid,lg_usertype,lg_username,lg_objid)
 values(@cuid,@ip,@device,@site,getdate(),@cmpid,@cutype,@cucallname,@cuobjid) 
 ---插入在线表
 insert into mps_online(ol_cmpid,ol_cuccid,ol_userid,ol_type,ol_name,ol_date,ol_firstonline,ol_ip,ol_addr,ol_device)
 values(@cmpid,@cuid,@cuobjid,@cutype,@cucallname,getdate(),getdate(),@ip,@site,@device) 
 set nocount off
  end