How convert varchar to int in sql?

How convert varchar to int in sql?

declare @a varchar(21) = '1000',
        @b varchar(21) = '   1000   '
       

select cast(@a as int) as a  
select cast(@b as int)  as b

2021-10-03