One possible reason is that it would lead to problems when a dynamic
default is used. The following example will only allow inserts 10
seconds of every minute:
create table test
(col1 nvarchar(1) default (datepart(second,current_timestamp)),
col2 nvarchar(1) null)
--
Gert-Jan
SQL Server MVP
bpdee wrote:
>
> Hi,
>
> Does anyone know why I am able to create a table such as follows?
>
> create table test
> (col1 nvarchar(1) default 'AA',
> col2 nvarchar(1) null)
> go
>
> Notice that I have a default value of 'AA' for a column that is defined as
> an nvarchar(1). SQL Server created the table without any errors.
>
> Of course, when I try to do an insert without specifying the column so that
> the default value would kick in, it gives me an error.
>
> insert into test
> (col2)
> values
> ('A')
> go
>
> Server: Msg 8152, Level 16, State 4, Line 1
> String or binary data would be truncated.
> The statement has been terminated.
>
> Thanks,
> Dee >> Stay informed about: Default constraints and values