I have read that UDF's in selects are bad.
Are all UDF's bad or does it depend on the UDF?
In the past I have used, but thought a UDF might be better because I format pone numbers in several procs.
Or maybe I should go back to formatting in .NET app.
I also have a UDF
Auguy
Sylvania/Toledo Ohio
Are all UDF's bad or does it depend on the UDF?
In the past I have used, but thought a UDF might be better because I format pone numbers in several procs.
Or maybe I should go back to formatting in .NET app.
Code:
SELECT Substring(CM.Phone,1,3) + ''-'' + Substring(CM.Phone,4,3) + '-' + Substring(CM.Phone,7,4) + ' ' + Substring(CM.Phone,11,10) END As CustPhoneStr
I also have a UDF
Code:
ALTER FUNCTION [dbo].[Udf_FormatPhoneNumber](@PhoneNbr VARCHAR(20))
RETURNS VARCHAR(23)
AS
BEGIN
DECLARE @PhoneFormatted VARCHAR(23)
IF (LEN(@PhoneNbr) < 10)
SET @PhoneFormatted = @PhoneNbr
ELSE
SET @PhoneFormatted = LEFT(@PhoneNbr, 3) + '-' + SUBSTRING(@PhoneNbr, 4, 3) + '-' + SUBSTRING(@PhoneNbr, 7, 4) + ' ' + SUBSTRING(@PhoneNbr, 11, 10)
RETURN @PhoneFormatted
END
END
Auguy
Sylvania/Toledo Ohio