This is code that I am using for years and that has not changed. This is part of a script to create a table where the field Numero is then define as the primary key:
PRINT 'Creating primary key Numero...'
BEGIN TRY
ALTER TABLE [Report]
ADD CONSTRAINT ReportNumero PRIMARY KEY (Numero)
END TRY
BEGIN CATCH
PRINT 'Error: Problem creating primary key Numero.'
PRINT ERROR_MESSAGE()
END CATCH
This results in this:
Creating primary key Numero...
Error: Problem creating primary key Numero.
Could not create constraint. See previous errors.
I cannot figure why in this particular table I cannot define the Numero field as Primary key.
This is an Integer field Not Null.
Anyone would know why?
This script is creating a brand new table. It only has about 10 records. I create all the fields from the script and all the indexes. This is the first index I am trying to create.