The primary difference between a function and a stored procedure is that the function must return a value, while it is optional in the stored procedure.