A function in SQL is a routine that takes parameters, performs an action, and returns a result, which can be a single value or a table. There are two main types of functions: user-defined functions (UDFs), which include table-valued and scalar-valued functions, and system-defined functions, which are predefined by SQL Server for specific purposes. Functions can only be used with select statements, must return a value, and do not support try-catch statements.