T-SQL Tutorial

Msg 137 Level 15 - Conversion failed when converting date and/or time from character string


On Transact SQL language the Msg 137 Level 15 - Must declare the scalar variable mean that the scalar variable is not declared or the variable name is misspelled or does not exist.

Msg 137 Level 15 Example:

Invalid statement:

USE model;
GO
SELECT @date AS 'My date';
GO

Message
Msg 137, Level 15, State 2, Line 1
Must declare the scalar variable "@date".

Correct statement:

USE model;
GO
DECLARE @date date= '08-28-2014';
SELECT @date AS 'My date';
GO

My date
2014-08-28

Other error messages: