Querying schema.table.column

  • michael.leach2015

    SSCommitted

    Points: 1584

    I am testing on the AdventureWorks database (the OLTP version, not the data warehouse version).  This version has the 'dbo' schema and other schemas to.  I am trying to run a simply query and I get an error stating invalid object name 'HumanResources.Employee.BusinessEntityID'.  Here is the code:

    SELECT *
    FROM [HumanResources].[Employee].BusinessEntityID;

    This doesn't work either:

    SELECT *
    FROM [Employee].BusinessEntityID;

    When I run this code, I get a result set:

    SELECT *
    FROM [HumanResources].[Employee];

    1. Why does the first query not work?
    2. How can I query the BusinessEntityID column if these queries don't work?

    I am in the AdventureWorks2017 database.

  • michael.leach2015

    SSCommitted

    Points: 1584

    Nevermind.  I see what I did wrong.  Only the schema and table should be in the FROM clause.  The column names should be in the SELECT statement.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply