--Write a function to validate phone number if it 10 digit or not

CREATE FUNCTION SCFN_Mobilevalidation 
(
@Mobile# nvarchar
)
RETURNS nvarchar
AS
BEGIN

DECLARE @Result nvarchar (20)
SELECT @Result = @Mobile#

if isnumeric(@Result) = 1 and len(@Result) = 10 
set @Result =
substring(@Result, 1,3) + 
substring(@Result, 3,9)  
else
set @Result = 'invalid entry'

RETURN @Result
END

been able to create the Function but how can i add  this to existing table for output


  Bijendra Kumar

Hi Bijendra,

This is not possible in SQL, by using SQL user defined Function you can't update a column in a table.


Thanks

  Devbrat Tripathi       12 Jan 2018       0       0     

Post Your Answers:

Please use the CODE HIGHLIGHT Button to format/highlight your codes if any