|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Wednesday, May 05, 2010 10:47 PM
Points: 93,
Visits: 98
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, May 30, 2013 9:36 AM
Points: 2,577,
Visits: 93
|
|
All queries failed due to missing Owner/Schema.
Example: Invalid... "FROM HumanResources.Employee" Valid... "FROM HumanResources..Employee" Valid... "FROM HumanResources.dbo.Employee"
Please review this and award points back.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 9:23 AM
Points: 2,819,
Visits: 1,044
|
|
HumanResources is the schema, so all queries were correctly qualified. The question specifically states that the database is AdventureWorks.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, September 24, 2012 8:10 AM
Points: 2,042,
Visits: 499
|
|
The only reason you would need the three part name was if you were referencing a different database [DatabaseName].[SchemaName].[TableName] on the same instance. In this case HumanResource is the schema so it is referencing it in this way: [SchemaName].[TableName]. As long as you are using the AdventureWorks database (USE AdventureWorks;) then the queries will execute (at least the ones that should!)
Cheers, Brian
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, April 05, 2012 2:35 PM
Points: 2,007,
Visits: 767
|
|
~Larry Briscoe (5/21/2009) All queries failed due to missing Owner/Schema. The queries that were supposed to run worked fine for me.
I think a potential issue in the question that could get tricky for some people is the SUM(VacationHours) in Query 1. The column VacationHours is defined as smallint. If someone is working on a modified their AdventureWorks database then the HumanResources.Employee table might have a substantial number of records added to it, or updates to the VacationHours column, such that summing VacationHours gives an overflow error.
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Thursday, November 22, 2012 8:43 AM
Points: 500,
Visits: 280
|
|
I have an unmodified AdventureWorks database and queries 1, 2, and 4 worked without issue for me. I was disappointed to find 1, 2, and 4 was not listed as an answer. I was forced to select all will work, which I knew was wrong but was the nearest answer to my findings.
More research should have been performed on this question.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 8:44 AM
Points: 220,
Visits: 357
|
|
I have an unmodified AdventureWorks database. 1 and 2 work fine. 3 and 4 fail.
3 gives:
Msg 207, Level 16, State 1, Line 2 Invalid column name 'EmployeeId'.
4 gives:
Msg 8127, Level 16, State 1, Line 2 Column "HumanResources.Employee.ManagerID" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
EDIT: this is MSSQL 2005 SP2 9.0.3073 64-bit
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, April 05, 2012 2:35 PM
Points: 2,007,
Visits: 767
|
|
ppcx (5/21/2009)
3 gives:
Msg 207, Level 16, State 1, Line 2 Invalid column name 'EmployeeId'.
Is your database collation case sensitive? That would be the reason "EmployeeId" is invalid, because it's actually "EmployeeID" (capital D) which is fine for case insensitive collation but an not for case sensitive.
Query 3 should give an error because EmployeeId is in the SELECT list but is not contained in the GROUP BY clause (or in an aggregate function within the SELECT list).
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, February 21, 2013 6:22 AM
Points: 1,074,
Visits: 1,205
|
|
Answer should be 1, 2 and 4 as well as 2nd and 4th query are same.
Mahesh
MH-09-AM-8694
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 10:23 AM
Points: 1,381,
Visits: 4,859
|
|
Mahesh Bote (5/27/2009) Answer should be 1, 2 and 4 as well as 2nd and 4th query are same.
Mahesh
Look more carefully - the second query is 'GROUP BY ManagerID' and will work, the 4th is 'ORDER BY ManagerID' and will fail.
|
|
|
|