{SQL Server} ajouter une contrainte dans sql
Résolu
ruskov
-
123 -
123 -
Bonsoir,
voici mon tableau
create table newproduct
(productid char(6) constraint pk_productid primary key,
productname varchar(20) not null,
productdescription varchar(250) not null,
categoryid char(3) constraint fk_categoryid foreign key references category(categoryid),
productrate money,
brandid char(3),
photo image,
qoh smallint constraint ck_qoh check(qoh between 0 and 200),
productimgpath varchar(50)
)
j'essaie d'ajouter une contrainte référentielle sur la colonne branid mais quand j'ustilise la requete :
"alter table newproduct
add constraint fk_brandid foreign key references productband(brandid) "
il s'affiche le message d'erreur suivant :"Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'."
quelqu'un peut il m'aider? merci d'avance je n'arrive pas à situer ou est l'erreur de syntaxe
voici mon tableau
create table newproduct
(productid char(6) constraint pk_productid primary key,
productname varchar(20) not null,
productdescription varchar(250) not null,
categoryid char(3) constraint fk_categoryid foreign key references category(categoryid),
productrate money,
brandid char(3),
photo image,
qoh smallint constraint ck_qoh check(qoh between 0 and 200),
productimgpath varchar(50)
)
j'essaie d'ajouter une contrainte référentielle sur la colonne branid mais quand j'ustilise la requete :
"alter table newproduct
add constraint fk_brandid foreign key references productband(brandid) "
il s'affiche le message d'erreur suivant :"Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'."
quelqu'un peut il m'aider? merci d'avance je n'arrive pas à situer ou est l'erreur de syntaxe
Configuration: Windows XP Firefox 3.5.5
4 réponses
-
Bonsoir,
Je crois qu'il manque le nom de la table derrière FOREIGN KEY
Essaye ça
"alter table newproduct
add constraint fk_brandid foreign key productband references productband(brandid) " -
c'est ça je l'ai remarqué tout à l'heure aprés avoir failli cassé mon écran
merci -
Doucement ... ça coute cher ces chose là !!! ^^
Bonne soirée alors ! -