b2977053
12/13/2019 - 9:52 AM

string_function_SUBSTRING

PRINT SUBSTRING('A-B-C-D-E-F', 3, 1); -- B
PRINT SUBSTRING('A-B-C-D-E-F', 3, 2); -- B-
PRINT SUBSTRING('A-B-C-D-E-F', 3, 3); -- B-C

--gmail.com
DECLARE @Email NVARCHAR(100);
SET @Email = '123456@gmail.com';
PRINT SUBSTRING(@Email, ( CHARINDEX('@', @Email) + 1 ),( LEN(@Email) - CHARINDEX('@', @Email) )); -- gmail.com