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

Last reviewed: March 20, 1997
Article ID: Q141665
6.00 WINDOWS kbusage kbdocerr kberrmsg kbbug6.00

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 reference words: SQL6 6.00 winnt
KBCategory: kbusage kbdocerr kberrmsg kbug6.00
KBSubcategory: SSrvDoc_Err
Keywords : kbusage SSrvDoc_Err
Version : 6.00
Platform : WINDOWS
Issue type : kbdocerr


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 20, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.