Functions are computed values and cannot perform permanent environmental changes to SQL Server (ie no INSERT or UPDATE statements allowed).
(函数是计算值,不能对SQL Server进行永久的环境更改(即,不允许INSERT或UPDATE语句)。)
A function can be used inline in SQL statements if it returns a scalar value, or can be joined upon if it returns a result set.
(如果函数返回标量值,则可以在SQL语句中内联使用;如果返回结果集,则可以将其加入。)
A point worth noting from comments, which summarize the answer.
(注释总结了答案,这一点值得一提。)
Thanks to @Sean K Anderson: (感谢@Sean K Anderson:)
Functions follow the computer-sciency definition in that they MUST return a value and cannot alter the data they receive as parameters (the arguments).
(函数遵循计算机科学的定义,因为它们必须返回一个值,并且不能更改作为参数(自变量)接收的数据。)
Functions are not allowed to change anything, must have at least one parameter, and they must return a value. (函数不允许更改任何内容,必须至少具有一个参数,并且它们必须返回一个值。)
Stored procs do not have to have a parameter, can change database objects, and do not have to return a value. (存储的proc不必具有参数,可以更改数据库对象,也不必返回值。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…