Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Scalar Function - Format Numbers

$
0
0
HiI have this function [quote]CREATE FUNCTION [dbo].[fnFormatMobileNumber] (@phone VARCHAR(15))RETURNS VARCHAR(15)AS BEGINDECLARE @Formatted VARCHAR(15)IF (LEN(@phone) > 10) SET @Formatted = '0' + SUBSTRING(@phone,3,9) ELSE SET @Formatted = @phoneRETURN @FormattedEND select [dbo].[fnFormatMobileNumber](0842507889) [/quote]I get 842507889 back when I execute this, and I'm expecting 0842507889, please help

Viewing all articles
Browse latest Browse all 3145

Trending Articles