Quantcast
Channel: Recent Edits
Viewing all articles
Browse latest Browse all 12198

Parameter defaults can not be a non-deterministic function

$
0
0
The default value for a parameter has to be a constant or NULL. You cannot use non-deterministic functions e.g. GETDATE() as default values. The workaround is to declare the default values as a NULL and use a ISNULL or COALESCE function in the procedure body to assign a value to the parameter variable.E.g.create procedure dbo.spMyProc (@d datetime = null)asbeginselect @d = coalesce(@d, getdate()) /*assign a default value*/select @dend

Viewing all articles
Browse latest Browse all 12198

Trending Articles