Try to run this script, first in any database under SQL-2000, then in SQL-2005:
select COLUMN_DEFAULT from INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_DEFAULT IS NOT NULL
In SQL-2000 values of the defaults are in single pair of brackets:
COLUMN_DEFAULT
('')
(0)
('')
(0)
(0)
(getdate())
(db_name())
(1)
(21)
(N'anonymous')
In SQL-2005 integer values are in double brackets, and all other defaults - in single brackets:
COLUMN_DEFAULT
('')
((0))
('')
((0))
((0))
(getdate())
(db_name())
((1))
((21))
(N'anonymous')
At the same time, OpenSchema method of ADO:
Connection.OpenSchema(adSchemaColumns)
returns different defaults in SQL2000 and SQL2005. In SQL2000 column defaults are in useful form, without any brackets:
'', 0, getdate()
But in SQL2005 they are enclosed in single brackets:
(''), (0), (getdate())
Does anybody know this problem? Is it normal, or it's a bug?
SQL Server 2005 normalizes expressions in defaults, check constraints and computed columns. As a result of this, the expression will look different from how it was stored in SQL Server 2000. However a particular expression will look the same irrespective of how you write it (extra spaces, paranthesis etc). This is documented in the following BOL topic:
http://msdn2.microsoft.com/en-us/library/ms143359.aspx
|||
Now I understand!
Thanks!
No comments:
Post a Comment