Failed to execute query. Error: Invalid object name 'SalesLT.ProductCategory'.

JUN LIANG ZHANG 21 Reputation points
2022-03-29T08:53:40.743+00:00

I just start to study SQL, I study follow the guide of Microsoft learn, there is an excise to ask me to put below SQL query into the editor pane:

SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
FROM SalesLT.ProductCategory pc
JOIN SalesLT.Product p
ON pc.productcategoryid = p.productcategoryid;

when I entered it, I selected "run" button, it appears "Failed to execute query. Error: Invalid object name 'SalesLT.ProductCategory'."

I shall appreciate any suggestions.

Azure SQL Database
{count} votes

Accepted answer
  1. Anurag Sharma 17,476 Reputation points
    2022-03-29T11:18:13.46+00:00

    Hi @JUN LIANG ZHANG , thanks for replying back.

    Can you please expand tables to know if the tables exist there as mentioned in below screenshot:

    187886-image.png

    It should show something like below:

    187895-image.png

    If these tables are not there, that means some problem while creating the database.

    I went through the article, can you please check if you have selected the option 'sample' while creating the database as highlighted in below screenshot. By default this option is not selected so you have to manually select this.

    187810-image.png

    If not, then you need to recreate the database and keep the 'sample' option selected and then try again.

    Please let me know if this helps or else we can discuss further.

    ----------

    If answer is helpful please click on 187849-image.png as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions. Thank you for helping to improve Microsoft Q&A!

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. JUN LIANG ZHANG 21 Reputation points
    2022-03-29T11:50:47.187+00:00

    Hello @AnuragSharma-MSFT

    Yes, you're correct, I made mistake at "sample"

    I recreated a new SQL database and per the guide to reset everything, now it works.

    Thank you very much and have a good day

    0 comments No comments