Reputation: 562
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'.
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'.
All the names are correct.
Can someone help me?
Upvotes: 4
Views: 3874
Reputation: 17590
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:
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
Upvotes: 4