IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_login_auto]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_login_auto]
GO
CREATE proc [dbo].[mps_login_auto]
@cmpid int,
@cuid int,
@ip varchar(30),
@device varchar(30),
@site varchar(200)
as
begin 
set nocount on
--判断所给定的ID是否存在
declare @finalid int
select @finalid =cu_id from mps_login where cu_id=@cuid
--如果存在则写日志,并登录
if(@finalid is not null)
begin
exec mps_login_userinfo @cuid --查询用户信息
exec mps_login_log @ip,@device,@cuid,@cmpid,@site
end

select '1' as result

end