Microsoft KB Archive/141665

{|
 * width="100%"|

BUG:Table-Level Default Constraint in CREATE TABLE Gives Error

 * }

Q141665

-

The information in this article applies to:


 * Microsoft SQL Server version 6.0

-

BUG# NT: 12551 (6.00)

SYMPTOMS
If you include a table-level default constraint in a CREATE TABLE statement, you will receive the following error:

Msg 170; Severity 15; State 1:

Incorrect syntax near 'for'

WORKAROUND
Use column-level default constraints. For example, rewrite the above SQL statement as:

create table tbldef (x int not null constraint cdef default 999, y int) go

STATUS
Microsoft has confirmed this to be a problem in SQL Server version 6.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
SQL Server "Books Online" and the "Transact-SQL Reference" manual (page 67) mention that table-level default constraints can be defined inside a CREATE TABLE statement. This is a documentation error. The following statement will give a syntax error:

create table tbldef (x int not null, y int, constraint cdef default 999 for x) go Additional query words: SQL6 winnt

Keywords : kbusage

Issue type :

Technology : kbSQLServSearch kbAudDeveloper kbSQLServ600