Use*_*ser 2 sql-server stored-procedures syntax-error
我已经使用两个输入参数和两个输出参数成功创建了一个存储过程.当我执行这个程序时,我收到一个错误
' - '附近的语法不正确
靠近第一个参数.
ALTER PROCEDURE [dbo].[Agent_interactions_report]
(
@StartDate date,
@EndDate date,
@ERRORCODE AS INT OUTPUT,
@ERRORDESCRIPTION AS VARCHAR(4000) OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
begin Try
select
cast([CallStartTime] as Date) as Date,
[AgentID] as [Agent ID], [Agent_Name] as [Agent name],
[CustomerID] as [Cust-ID], [Account_Number] as [Account number],
[Transaction_Des] as [Transaction],
CallStartTime AS [Call start time],
CallEndTime AS [Call end time], CallID as [Call ID]
from
[TBL_AGENT_TRANSACTIONS]
where
cast(CallStartTime as DATE) >= @StartDate
and cast(CallEndTime as Date) <= @EndDate
end Try
begin catch
SET @ERRORCODE = ERROR_NUMBER()
SET @ERRORDESCRIPTION = ERROR_MESSAGE()
end catch
END
Run Code Online (Sandbox Code Playgroud)
这是执行结果:
DECLARE @return_value int,
@ERRORCODE int,
@ERRORDESCRIPTION varchar(4000)
EXEC @return_value = [dbo].[Agent_interactions_report]
@StartDate = 2015-04-27,
@EndDate = 2015-04-27,
@ERRORCODE = @ERRORCODE OUTPUT,
@ERRORDESCRIPTION = @ERRORDESCRIPTION OUTPUT
SELECT @ERRORCODE as N'@ERRORCODE',
@ERRORDESCRIPTION as N'@ERRORDESCRIPTION'
Run Code Online (Sandbox Code Playgroud)
我在"@StartDate = 2015-04-27"附近收到错误,但是当我通过输入输入参数手动执行SP时,我得到了预期的结果.
注意:
由于我的声誉低于10,我不应该上传截图,这对于理解这个问题会更有用.如果您需要更多信息,请告诉我.
归档时间: |
|
查看次数: |
5863 次 |
最近记录: |