Results 1 to 5 of 5

Thread: autonumber

  1. #1
    Join Date
    Jan 2004
    Posts
    51

    Unanswered: autonumber

    sql 2000

    how can i set primary key to autonumber?
    i created a form with this table,, i get error when trying to insert..
    i want "id: column to autogenerate number
    .................................................. .....................................

    [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'id', table 'Guestbook.dbo.guestbook'; column does not allow nulls. INSERT fails.

  2. #2
    Join Date
    Mar 2003
    Location
    Indiana, USA
    Posts
    100

    Re: autonumber

    FYI:

    You need to create the Primary Key using IDENTITY [ ( seed , increment )

    Tim S

    From BOL ( Books On Line)

    CREATE TABLE
    [ database_name.[ owner ] . | owner. ] table_name
    ( { < column_definition >
    | column_name AS computed_column_expression
    | < table_constraint > ::= [ CONSTRAINT constraint_name ] }

    | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
    )

    [ ON { filegroup | DEFAULT } ]
    [ TEXTIMAGE_ON { filegroup | DEFAULT } ]

    < column_definition > ::= { column_name data_type }
    [ COLLATE < collation_name > ]
    [ [ DEFAULT constant_expression ]
    | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
    ]
    [ ROWGUIDCOL]
    [ < column_constraint > ] [ ...n ]

  3. #3
    Join Date
    Jan 2004
    Posts
    51
    is it possible to alter the table or column to make that changes?

  4. #4
    Join Date
    Mar 2003
    Location
    Indiana, USA
    Posts
    100
    I have not found a way to alter the Table to make the change.

    If use use the Enterprise Manager to change the column it creates a new table and copies the data into it and deletes the old table an renames the new table to match the old table name.

    Tim S

  5. #5
    Join Date
    Jan 2004
    Posts
    51
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •