BUG: Primary Key Can Incorrectly Include a Nullable ColumnLast reviewed: January 30, 1998Article ID: Q180189 |
The information in this article applies to:
SYMPTOMSIf the "Columns Null by Default" option is selected for a database, the following CREATE TABLE statement will create a table with a nullable column included in the primary key:
create table test(column1 varchar(12) CONSTRAINT mykey PRIMARY KEY (column1, column3), column2 varchar(2), column3 varchar(2))This statement should not allow the primary key to have a nullable column. Either the primary key should be created with all columns defined as not null, or the following error message should be returned:
Msg 8111, Level 16, State 0 Attempting to define PRIMARY KEY constraint on nullable column in table <table name>. WORKAROUNDTo work around this behavior, do either of the following:
create table test(column1 varchar(12), column2 varchar(2), column3 varchar(2), CONSTRAINT mykey PRIMARY KEY (column1, column3)) STATUSMicrosoft has confirmed this to be a problem in SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
|
Additional query words: ANSI_NULL_DFLT_ON
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |