Try_casting Sql_variant 列截断逗号后的值

Try_casting a Sql_variant column truncating the value after a comma

我有 sql_variant 类型的列 'Value'。它的价值

'Device Warning: Bus Transient, Warning Code: 164, Timestamp: 2015-12-23 13:02:48.750'

如果我尝试 select

TRY_CAST([Value] AS nvarchar) as varvalue

我得到值

Device Warning: Bus Transient,

我们如何在不丢失一些数据的情况下转换 sql_variant 类型?我需要将其转换为 nvarchar,因为我需要使用 SUBSTING 函数来提取部分值。

任何帮助将不胜感激!!!

nchar and nvarchar (Transact-SQL)

Remarks
When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30.

1> select len('Device Warning: Bus Transient,')
2> go

-----------
         30

指定长度。

QED