在 SQL Server 2014 中将 varchar 转换为时间失败

Conversion of varchar to time failed in SQL Server 2014

My table:

When I convert it to time, it fails while selecting from table:

But, when I test it in string, then there is no issue. What is the problem? I don't know.

我认为您的时间栏中有新的一行。请使用子字符串获取准确时间。

select CONVERT(time, substring(timout, 1, 5), 104) 
from tbl_test

转换会在时间为空或无效时产生问题,因此请使用 Len 函数。

select CONVERT(time, substring(timout, 1, 5), 104) 
from tbl_test  
where len(TimOut) > 4
select CONVERT(time, substring((CASE TimOut WHEN '0' THEN '00:00' ELSE TimOut END),1,5),104) from tbl_test