Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cannot create primary key
Message
De
27/03/2015 09:31:29
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Cannot create primary key
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01617314
Message ID:
01617314
Vues:
30
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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform