CREATE FUNCTION Fact (@parameter datatype) RETURNS returndatatype AS BEGIN --sql statements RETURN --whatever you want to return but of returndatatype from above END