4

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?

1
  • 2
    You cannot have expressions in the EXEC command - you need to have only literal values or SQL Server variables. Use a SQL Server variable to hold the result of the CONVERT and then use that variable in your EXEC call ... Commented Oct 31, 2013 at 8:45

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.