add primary constraint primary key error!

  • hi.I wrote these commands and There is a problem.

    -----tablo1 a1 column name=PK1 a Primary add constraint

    Use test

    GO

    ALTER TABLE tablo1 ADD CONSTRAINT PK1 PRIMARY KEY (a1)

    GO

    error messages:

    Msg 8111, Level 16, State 1, Line 1

    Cannot define PRIMARY KEY constraint on nullable column in table 'tablo1'.

    Msg 1750, Level 16, State 0, Line 1

    Could not create constraint. See previous errors.

  • you will need to alter the column to be not null and then create the primary key

  • thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply