Why does this statement succeed?
SELECT CAST('08:50' as time)
But this one fails? tmrec is an nvarchar(6) column and contains the same value '08:50'. This is making me crazy since last 1 hour.
SELECT TOP 1 CAST(tmrec as time)
FROM Instr
WHERE igrp = 'JD'
ORDER BY ino , smallin
This screenshot shows the 1st query's result. It contains 08:50. Yet the 2nd query throws error.
Edit:
Even this doesn't work which guarantees that conversion is applied only on fetched records:
SELECT CAST( tmrec as time)
FROM
(
SELECT TOP 1 tmrec
FROM [ccwise-courts].[dbo].[INSTR]
WHERE igrp = 'JD'
ORDER BY ino , smallin
) v