The reason behind the identifier could not be resolved error in your CosmosDB queries

When writing SQL queries to test them against your CosmosDB collections, you might encounter the following error message:

Identifier XXX could not be resolved.

Here, XXX is the name of a property inside your collection. For example, consider the following query:

SELECT * FROM students WHERE firstname = 'Christos'

The reason for the error is that you forgot to include the name of the collection or the alias name for each property you use. Here are the correct examples:

SELECT * FROM students WHERE students.firstname = 'Christos'

Using an alias for the name of the collection:

SELECT * FROM students AS s WHERE s.firstname = 'Christos'

A useful playground for your CosmosDB queries can be found on this website

comments powered by Disqus