我在修复存储过程没有输入参数的问题时出现问题,在SQL代理作业中失败,期望输入参数。
任何想法或简单的解决方案!洛尔
这是代理工作电话: 执行e3.dbo.storeproc_name
这是存储过程:
CREATE PROCEDURE [dbo].[storeproc_name]
@EmpNo nchar(10) Output,
@EmpLN nchar(50) Output,
@EmpFN nchar(50) Output,
@FOB bit Output,
@SecAcc bit Output,
@Network bit Output,
@VPN bit Output,
@Email bit Output,
@Printer bit Output,
@Fuel bit Output,
@BSTC bit Output,
@Accounts bit Output,
@Telephone bit Output,
@Alarm bit Output,
@EZPass1 bit Output,
@EZPass2 bit Output,
@EmpReqID int Output,
@ReqDate Datetime Output
AS
BEGIN
SET NOCOUNT ON;
-- Check FOB Change Request
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_FOBadge <> E.Emp_CA_Badge_No1)
OR (ERA.Emp_FOBadge <> E.Emp_CA_Badge_No1)
)
SET @FOB = 'True'
ELSE
SET @FOB = 'False'
-- Check Secondary Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_Sec_Access = 'True') AND (EA.EA_Sec_CA = 'False')
)
SET @SecAcc = 'True'
ELSE
SET @SecAcc = 'False'
-- Check Network Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_NetworkID <> 'True') AND (EA.EA_Network = 'False')
)
SET @Network = 'True'
ELSE
SET @Network = 'False'
-- Check VPN Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_VPN = 'True')
AND (EA.EA_VPN = 'False')
)
SET @VPN = 'True'
ELSE
SET @VPN = 'False'
-- Check EMAIL Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_Email = 'True')
AND (EA.EA_Email = 'False')
)
SET @Email = 'True'
ELSE
SET @Email = 'False'
-- Check Local Printer Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_LocalPrinter = 'True')
AND (EA.EA_Printer = 'False')
)
SET @Printer = 'True'
ELSE
SET @Printer = 'False'
-- Check FuelSystem Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_FuelSystem = 'True')
AND (EA.EA_FuelSystem = 'False')
)
SET @Fuel = 'True'
ELSE
SET @Fuel = 'False'
-- Check BSTC Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_BSTC = 'True')
AND (EA.EA_BSTC = 'False')
)
SET @BSTC = 'True'
ELSE
SET @BSTC = 'False'
-- Check Misc Accounts Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_Accounts <> '')
AND (EA.EA_Accounts = '0' OR EA.EA_Accounts = '')
)
SET @Accounts = 'True'
ELSE
SET @Accounts = 'False'
-- Check Alarm Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_Alarm = 'True')
AND (EA.EA_Alarm = 'False')
)
SET @Alarm = 'True'
ELSE
SET @Alarm = 'False'
-- Check Telephone Access
If Exists
(
SELECT ERA.Emp_LastName AS [@EmpLN], ERA.Emp_FirstName AS [@EmpFN], ERA.Emp_DtAudStep_Complete AS [@ReqDate], ERA.Emp_ReqID as [@EmpReqID]
FROM [e3].[dbo].E3_Emp_ReqAudit AS ERA INNER JOIN
[e3].[dbo].E3_Emp_Access AS EA ON ERA.Emp_AB_No = EA.EA_AB_No INNER JOIN
[e3].[dbo].E3_Employee AS E ON ERA.Emp_AB_No = E.Emp_AB_No
WHERE (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (ERA.Emp_Req_Action = 'E1') AND (ERA.Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')
AND (ERA.Emp_DtAudStep_Complete =
(SELECT MAX(Emp_DtAudStep_Complete) AS Expr1
FROM [e3].[dbo].E3_Emp_ReqAudit AS E3_Emp_ReqAudit_1
WHERE (Emp_AB_No = EA.EA_AB_No)
AND (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '5') AND (ERA.Emp_Contractor = 'False')
OR (Emp_Req_Action = 'E1') AND (Emp_AudStep_Completed = '2') AND (ERA.Emp_Contractor = 'True')))
AND ERA.Emp_DtAudStep_Complete <= dateadd(day,-1,GETDATE())
AND (ERA.Emp_Telephone = 'True')
AND (EA.EA_Telephone = 'False')
)
SET @Telephone = 'True'
ELSE
SET @Telephone = 'False'
END