C
C#2mo ago
yummy_bee

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.
No description
22 Replies
FusedQyou
FusedQyou2mo ago
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
yummy_bee
yummy_beeOP2mo ago
do you mean like this?
No description
FusedQyou
FusedQyou2mo ago
Yes, guess that aint it I tried replicating the SQL and it was valid for me
yummy_bee
yummy_beeOP2mo ago
Hmm yeah okay weird
FusedQyou
FusedQyou2mo ago
Can you copy paste the code in here?
yummy_bee
yummy_beeOP2mo ago
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;
FusedQyou
FusedQyou2mo ago
Sorry. No idea. This looks valid to me
yummy_bee
yummy_beeOP2mo ago
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
FusedQyou
FusedQyou2mo ago
I'm sure somebody else would know
yummy_bee
yummy_beeOP2mo ago
yeah okay thank you
FusedQyou
FusedQyou2mo ago
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 error
yummy_bee
yummy_beeOP2mo ago
yeah i get more errors so it might be somthing else that is wrong
Angius
Angius2mo ago
Try quoting the table names
yummy_bee
yummy_beeOP2mo ago
like this?
No description
Angius
Angius2mo ago
Table names
yummy_bee
yummy_beeOP2mo ago
I tried that and I still get the same error unfortunately
Angius
Angius2mo ago
What SQL dialect is that?
yummy_bee
yummy_beeOP2mo ago
I am not sure I think standard sql We work in microsoft SQL server
Angius
Angius2mo ago
T-SQL then Huh, should just work
yummy_bee
yummy_beeOP2mo ago
Yeah I know it’s weird
Angius
Angius2mo ago
It works just fine in OneCompiler ¯\_(ツ)_/¯ https://onecompiler.com/sqlserver/42tepjjsf Though I do use " instead of ' for strings here
yummy_bee
yummy_beeOP2mo ago
Yeah, if it works in the compiler it should be fine maybe it’s just a problem on my computer
Want results from more Discord servers?
Add your server