Sql custom function call - tsql

I am doing the following:

    Insert into table1 
   (Phone#) values @Phone

      

There is a special function that will format the phone number. It takes a phone number as input and returns a formatted version.

I've tried the following, but I'm not sure if it won't work:

    Insert into table1 
   (Phone#) values fn_phone(@Phone)

      

It says fn_phone is not a recognized built-in function name. Am I doing something wrong, what am I calling fn_phone?

+3


source to share


3 answers


Use two part name when you call UDF

Try the following:



Insert into table1  
   (Phone#) select dbo.fn_phone(@Phone) 

      

+7


source


try:



Insert into table1 (Phone#) 
SELECT dbo.fn_phone(@Phone) (or whatever schema your function is in)

      

+1


source


Assuming the function belongs to the "dbo" schema:

    Insert into table1 
   (Phone#) values (dbo.fn_phone(@Phone))

      

0


source







All Articles