You can implement your own functions in SQL using the CREATE FUNCTION statement. The RETURN statement inside the CREATE FUNCTION statement determines the data type of the function.
Once you have created a SQL user-defined function, you can use it anywhere a built-in function of the same data type is used.
For more information on creating SQL functions, see System Administration Guide: Volume 2 > Using Procedures and Batches.