Jump to content

MS SQL Server Error


phpmania

Recommended Posts

Hi

 

"Msg 1769, Level 16, State 1, Line 25

Foreign key 'AsstNo' references invalid column 'AsstNo' in referencing table 'ExpenseItem'."

 

i'm getting this error as i try to execute a bunch of tables into ms sql server. Here are the tables if anyone would be so kind as to have a look;

 

create table ExpenseItem (

EINo integer,

ExpDesc varchar(255) not null,

ExpenseDate datetime default getdate(),

ExpAmt money default (0) not null,

ExpApprAmt money default (0),

ERNo integer not null,

ECNo integer not null,

AssetNo integer not null,

PRIMARY KEY (EINo),

FOREIGN KEY (ERNo) References ExpenseReport,

FOREIGN KEY (ECNo) References ExpCat,

FOREIGN KEY (AsstNo) References Asset);

 

create table Asset (

AssetNo integer,

AssetDesc varchar(255) not null,

PRIMARY KEY (AssetNo));

 

There are other tables but these seem to be the ones with the errors. Hope someone can give me some indication as to whats wrong. Cheers!

Link to comment
Share on other sites

Hi there,

 

I was doing some research about your error and it looks this error message appears when you try to create a FOREIGN KEY constraint on a column that does not exist in the referenced table. Error of the Severity Level 16 are generated by the user and are correctable by the user. The statement cannot be executed this way. FOREIGN KEY constraints can only reference columns that do exist at the time when the constraint is created.

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.