Friday, May 4, 2012

SQL Server Error Messages - Msg 139

Server: Msg 139, Level 15, State 1, Line 1 Cannot assign a default value to a local variable.
如果你在sql server 2008 的环境下习惯给declare 的variable assign default value
DECLARE @CurrentDate DATETIME = GETDATE()
你在sql server 2005 跑上面的statement的话,你会遇到以下的error:
Msg 139, Level 15, State 1, Line 0 Cannot assign a default value to a local variable.
要避免以上的error, 可以用以下的query:
DECLARE @CurrentDate DATETIME SET @CurrentDate = GETDATE()

_________________________________________________________________
_________________________________________________________________

1 comment:

LinkWithin

Related Posts with Thumbnails