Sql Server Errors: The name “DATETIME” is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
- Posted by Sqltimes
- On March 21, 2015
- 0 Comments
Quick one today:
Recently, I ran into this interesting error message. The actions that resulted in this error are silly, but the message is interesting. The language used in the error message dignifies the actions to the same level as other valid error messages. But in my opinion these actions are silly and it is nice of Microsoft to be kind and gentle on us.
Code that resulted in this error:
1
2
3
4
5
|
-- -- Incorrect -- PRINT 'Purged Ended on : ' + CONVERT ( VARCHAR , DATETIME) GO |
Interesting error:
Msg 128, Level 15, State 1, Line 11 The name "DATETIME" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Corrected code sample that works:
1
2
3
4
5
|
-- -- Correct -- PRINT 'Purged Started on : ' + CONVERT ( VARCHAR , GETDATE()) GO |
Hope this helps,
_Sqltimes
_Sqltimes
0 Comments