Where can I find the list of functions that can be used for Default Value or Binding?
I need a list of funct开发者_StackOverflowions that can be invoked in a Default Value or Binding
column.
Where can I find them?
DEFAULT constraints can be any 'system function' or a literal:
a literal value, a NULL, or a system function used as the default column value.
The term 'system function' is a bit ambiguous. None the less, there is a list of system built-in functions at Built-in Functions (Transact-SQL). For DEFAULT constraints only scalar functions are supported, and the MSDN separates scalar function into topics, but it obviously fails to follow trough with this separation as for instance Scalar Functions lists all 'System Statistical Functions' and the later lists fn_virtualfilestats
which is obviously not scalar. Also certain functions cannot be used in any context and will not be possible to be used as DEFAULT constraint, eg. IDENTITY
(the less known function, not the well known column property).
Although one can apparently write a short novel about what system functions can and what cannot be used as a DEFAULT constraint, in practice there is only a small handfull of functions that make sense to be used, like GETDATE()
, ORIGINAL_LOGIN()
, NEWID()
and NEWSEQUENTIALID()
. Just to end on a high note, the latter is rather interesting as is a function that can be used only in a DEFAULT constraint.
精彩评论