create function replacePhoneNumberVanityChars(@string varchar(max)) returns varchar(max) begin declare @len as int = len(@string); declare @i as int = 1; declare @char as varchar(1) = null; while(@i<=@len) begin set @char = right(left(@string,@i),1); if(@char in ('A','B','C')) set @char = '2'; if(@char in ('D','E','F')) set @char = '3'; if(@char in ('G','H','I')) set @char = '4'; if(@char in ('J','K','L')) set @char = '5'; if(@char in ('M','N','O')) set @char = '6'; if(@char in ('P','Q','R','S')) set @char = '7'; if(@char in ('T','U','V')) set @char = '8'; if(@char in ('W','X','Y','Z')) set @char = '9'; set @string = left(@string,@i-1) + @char + right(@string,len(@string)-@i); set @char = null; set @i = @i +1; end return @string; end
Friday, July 31, 2015
Replace Vanity Phone Numbers with Numbers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment