SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 FOREIGN KEY ERRORS.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/02/2013 :  17:57:16  Show Profile  Reply with Quote
Below is the table i created and when i execute, I get this error.

CREATE TABLE ITEMS_ITEMDETAILS
(
ItemID int Identity(2,2) PRIMARY KEY ,
ItemName Varchar (50) not null,
ItemDescription Varchar (50) not null,
QuantityInHand int,
CONSTRAINT check_ID1 CHECK (QuantityInHand >= 0 ),
UnitPrice Money,
CONSTRAINT check_ID2 CHECK (UnitPrice >= 0 ),
ReorderQuantity int,
CONSTRAINT check_ID3 CHECK (ReorderQuantity >= 0 ),
ReorderLevel int ,
CONSTRAINT check_ID4 CHECK (ReorderLevel >= 0)
CategoryID int constraint fkey_CategoryID Foreign Key References ITEMS_PRODUCTCATEGORY(CategoryID)
SupplierID int constraint fkey_SupplierID Foreign Key References SUPPLIER_SUPPLIERDETAILS (SupplierID)
)


Msg 102, Level 15, State 1, Line 14
Incorrect syntax near 'CategoryID'.


Best Regards.

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 10/03/2013 :  03:54:55  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Try checking your commas.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 10/03/2013 :  03:55:01  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Try checking your commas.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/04/2013 :  01:52:13  Show Profile  Reply with Quote
you've 2 commas missing at the end

CREATE TABLE ITEMS_ITEMDETAILS
(
ItemID int Identity(2,2) PRIMARY KEY ,
ItemName Varchar (50) not null,
ItemDescription Varchar (50) not null,
QuantityInHand int,
CONSTRAINT check_ID1 CHECK (QuantityInHand >= 0 ),
UnitPrice Money,
CONSTRAINT check_ID2 CHECK (UnitPrice >= 0 ),
ReorderQuantity int,
CONSTRAINT check_ID3 CHECK (ReorderQuantity >= 0 ),
ReorderLevel int ,
CONSTRAINT check_ID4 CHECK (ReorderLevel >= 0),
CategoryID int constraint fkey_CategoryID Foreign Key References ITEMS_PRODUCTCATEGORY(CategoryID),
SupplierID int constraint fkey_SupplierID Foreign Key References SUPPLIER_SUPPLIERDETAILS (SupplierID)
)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000