简体   繁体   English

SQL Server存储过程的语法错误

[英]Syntax error with SQL Server stored procedure

I recently wrote a stored procedure with those parameters: 我最近用这些参数编写了一个存储过程:

@dFromDT DATE,
@dToDT DATE,
@sErrorMessage NVARCHAR(MAX),
@sPartCustom INT,
@sPartCustomFilter NVARCHAR(254),
@nIncludeMessage INT

I am trying to call the procedure with the line: 我试图用行调用该过程:

EXEC _MG_ERPPartFilter(CONVERT(datetime, '2013-01-01T00:00:00', 126), CONVERT(datetime, '2050-12-31T00:00:00', 126), '',5, '556', 0)

And I always get that error message: 我总是收到错误消息:

Incorrect syntax near the keyword 'CONVERT'. 关键字“CONVERT”附近的语法不正确。

Even when I write this line: 即使我写这行:

EXEC _MG_ERPPartFilter('2013-01-01','2050-12-31', '',5, '556', 0)

I get that error: 我收到了这个错误:

Incorrect syntax near '2013-01-01'. '2013-01-01'附近的语法不正确。

All the names are correct. 所有的名字都是正确的。

Can someone help me? 有人能帮我吗?

Do not use parenthesis in your second example: 在第二个示例中不要使用括号:

EXEC _MG_ERPPartFilter '2013-01-01','2050-12-31', '',5, '556', 0

and in first you have to convert values into temporary variables and pass them to exec command: 首先,您必须将值转换为临时变量并将它们传递给exec命令:

declare @date1 datetime, @date2 datetime

set @date1 = CONVERT(datetime, '2013-01-01T00:00:00', 126)
set @date2 = CONVERT(datetime, '2050-12-31T00:00:00', 126)

EXEC _MG_ERPPartFilter @date1, @date2, '',5, '556', 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM