phpmania Posted March 3, 2009 Share Posted March 3, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/147750-ms-sql-server-error/ Share on other sites More sharing options...
BMurtagh Posted March 6, 2009 Share Posted March 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/147750-ms-sql-server-error/#findComment-778458 Share on other sites More sharing options...
phewett Posted March 14, 2009 Share Posted March 14, 2009 lookslike you have a typo in your code to me : AssetNo integer not null, has an "e" FOREIGN KEY (AsstNo) References Asset); doesn't have a "e" Is that your problem ? (NOte : I'm a complete SQL newbie) Quote Link to comment https://forums.phpfreaks.com/topic/147750-ms-sql-server-error/#findComment-784879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.