Talk:SQL Exercises/The warehouse

MS SQL 2005

"Msg 1919, Level 16, State 1, Line 7 Column 'Code' in table 'Boxes' is of a type that is invalid for use as a key column in an index. Msg 1750, Level 16, State 0, Line 7 Could not create constraint. See previous errors. " MS SQL 2012

"Msg 2714, Level 16, State 5, Line 3 There is already an object named 'fk_Physician_EmployeeID' in the database. Msg 1750, Level 16, State 0, Line 3 Could not create constraint. See previous errors. "


 * Should this be fixed by changing TEXT to INTEGER? Magicalsushi (talk) 15:23, 15 July 2010 (UTC)
 * Oops, nope apparently not, if you want to work with the data set as given. Magicalsushi (talk) 15:27, 15 July 2010 (UTC)
 * Changing it to VARCHAR(20) or suchlike does work though (in Transact-SQL, at least). Problem solved! :) Magicalsushi (talk) 15:41, 15 July 2010 (UTC)

sqlite3 3.8.10.2 2015-05-20 (but universally applicable 8-) Regarding the optional part of this problem: "Select the warehouse codes, along with the number of boxes in each warehouse. Optionally, take into account that some warehouses are empty (i.e., the box count should show up as zero, instead of omitting the warehouse from the result)." The given data (i.e., INSERT statements) do not include data that would show the optional part (requiring a LEFT JOIN) is working. One remedy is to add this to the list of INSERTs: INSERT INTO Warehouses(Code,Location,Capacity) VALUES(6,'Denver',5); ,,, This inserts a warehouse which has no boxes in it. DonaldCameron77 (discuss • contribs) 18:33, 17 May 2016 (UTC)