I did a simple test.
select CastVARCHAR = CAST ('14.0' AS INT)
An error is reported.
If you want to get 14, you can try replacing int with DECIMAL(2,0).
SELECT TryCastNumber = TRY_CAST (14.0 AS INT)
, TryCastVARCHAR = TRY_CAST ('14.0' AS DECIMAL(2,0))
, TryParseVARCHAR = TRY_PARSE ('14.0' AS INT)
Output:
Best regards,
Percy Tang
If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.