What's the syntax error?
-
What's the syntax error in the following TSQL stored procedure call?
EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;
SSMS is telling me "Syntax error near keyword CONVERT"
The difficult we do right away... ...the impossible takes slightly longer.
-
What's the syntax error in the following TSQL stored procedure call?
EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;
SSMS is telling me "Syntax error near keyword CONVERT"
The difficult we do right away... ...the impossible takes slightly longer.
I typed it in as a Select and it worked fine. Changing it to and EXEC proc failed. Try converting the date then see.
DECLARE @DateT DateTime = Convert(DateTime, '09-09-2024 14:14:28')
EXEC StoredProcName 9,'12341239487','1', @DateT,'calculated','','','',0,0,0,0,0,0,0,0,0;This works fine for me. Raiserror is the same way, can't cast or convert inline.
Jack of all trades, master of none, though often times better than master of one.
-
I typed it in as a Select and it worked fine. Changing it to and EXEC proc failed. Try converting the date then see.
DECLARE @DateT DateTime = Convert(DateTime, '09-09-2024 14:14:28')
EXEC StoredProcName 9,'12341239487','1', @DateT,'calculated','','','',0,0,0,0,0,0,0,0,0;This works fine for me. Raiserror is the same way, can't cast or convert inline.
Jack of all trades, master of none, though often times better than master of one.
Thanks, Ron. I guess it's not a huge problem, but it is annoying!
The difficult we do right away... ...the impossible takes slightly longer.
-
What's the syntax error in the following TSQL stored procedure call?
EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;
SSMS is telling me "Syntax error near keyword CONVERT"
The difficult we do right away... ...the impossible takes slightly longer.
-
What's the syntax error in the following TSQL stored procedure call?
EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;
SSMS is telling me "Syntax error near keyword CONVERT"
The difficult we do right away... ...the impossible takes slightly longer.
If the parameter is typed as
datetime
, you shouldn't need to explicitly convert the string literal when you pass it in. However, it would probably be best to use the unambiguous date format (yyyyMMdd
):EXEC StoredProcedureName 9, '723147504', '1', '20240927 14:14:28', 'calculated', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0;
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
If the parameter is typed as
datetime
, you shouldn't need to explicitly convert the string literal when you pass it in. However, it would probably be best to use the unambiguous date format (yyyyMMdd
):EXEC StoredProcedureName 9, '723147504', '1', '20240927 14:14:28', 'calculated', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0;
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I'll give this a try when I'm back in my office.
The difficult we do right away... ...the impossible takes slightly longer.