deelliiee456

In LinqPad I wrote this querry CREATE TABLE InventoryTBLC ( itemID int NOT NULL IDENTITY(1,1) CONSTRAINT PK_items PRIMARY KEY, itemName NVARCHAR(150) NOT NULL, itemDesc NVARCHAR(150) NULL, itemQuantity int, itemPrice int, imagePath NVARCHAR(300), correctInsert NVARCHAR(300), realImage image, catID INT NOT NULL CONSTRAINT FK_item_Category FOREIGN KEY REFERENCES Category(catID) ); But it gives error "The constraint specified is not valid." Can someone tell me the correct syntax for adding foreign key

About

Username
deelliiee456
Joined
Visits
6
Last Active
Roles
Member
Badges
0

Activity

  • In LinqPad
    I wrote this querry
    CREATE TABLE InventoryTBLC (
    itemID int NOT NULL IDENTITY(1,1) CONSTRAINT PK_items PRIMARY KEY,
    itemName NVARCHAR(150) NOT NULL,
    itemDesc NVARCHAR(150) NULL,
    itemQuantity int,
    itemPrice int,
    imagePath NVARCHAR(300),
    correctInsert NVARCHAR(300),
    realImage image,

    catID INT NOT NULL CONSTRAINT FK_item_Category FOREIGN KEY REFERENCES Category(catID)

    );

    But it gives error "The constraint specified is not valid."

    Can someone tell me the correct syntax for adding foreign key
    February 14
    • deelliiee456
      deelliiee456
      I already have a Table named "Category" which has a Primary key "catID"
Avatar

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Badges

Any minute now…