C++ stoi equivalent in SQL Server's T-SQL
DECLARE @Test VARCHAR(32)

SET @Test = '99ABC 123ABCD ABC DEFGH'

DECLARE @stoi INT = TRY_CONVERT(INT, LEFT(LTRIM(@Test), PATINDEX('%[^0123456789]%', LTRIM(@Test + ';')) - 1))

SELECT @stoi



  99