SQL code
"Add a Quality Label table with a foreign key from the
Suppliers, with the default value corresponding to 'medium' quality. Don't forget to add a column to the
Suppliers for the foreign key.
Also add the following values to the table" we are using the northwind schema and i have tried to insert this but i keep getting invalid column name no matter what i change it to and i dont know why.
22 Replies
Put the first two lines on a single line maybe
The error is wrong
I assume it does this because the SQL before it is wrong
Otherwise idk, I let EntityFramework do my SQL rather than doing it manually
do you mean like this?
Yes, guess that aint it
I tried replicating the SQL and it was valid for me
Hmm yeah okay weird
Can you copy paste the code in here?
ALTER TABLE Suppliers
ADD QualityID int;
CREATE TABLE Quality (QualityID int PRIMARY KEY, QualityLevel varchar(20) NOT NULL);
INSERT INTO Quality (QualityID, QualityLevel)
VALUES
(0, 'Acceptable'),
(1, 'Medium'),
(2, 'High');
UPDATE Suppliers
SET QualityID = 1;
Sorry. No idea. This looks valid to me
when i hold the mouse over Quality it says there already is an object named Quality in the databse which is weird because there should not be
I'm sure somebody else would know
yeah okay thank you
Oh, then change your syntax to
CREATE TABLE IF NOT EXISTS
maybe
This would only make a table with the given name if it doesn't exist yet, otherwise it would throw an erroryeah i get more errors so it might be somthing else that is wrong
Try quoting the table names
like this?
Table names
I tried that and I still get the same error unfortunately
What SQL dialect is that?
I am not sure I think standard sql
We work in microsoft SQL server
T-SQL then
Huh, should just work
Yeah I know it’s weird
It works just fine in OneCompiler ¯\_(ツ)_/¯
https://onecompiler.com/sqlserver/42tepjjsf
Though I do use
"
instead of '
for strings hereYeah, if it works in the compiler it should be fine maybe it’s just a problem on my computer