1> 2> DECLARE @FullName VarChar(25) 3> SET @FullName = 'www.java2s.com' 4> 5> SELECT SUBSTRING(@FullName, 1,CHARINDEX('java2s', @FullName) - 1) 6> GO ------------------------- www. (1 rows affected) 1>