Image

User-defined functions

Anyone have experience with user-defined functions? I'm trying to write one that takes two parameters; it returns the first one if it's not NULL, otherwise it returns the second one. like this:

CREATE FUNCTION loginName.functionName (@val1 int, @val2 int)
RETURNS (int) AS  
BEGIN 
(FUNCTION BODY) 
END
I don't know what to put in "(FUNCTION BODY)". Anyone?