1
votes

Question: What is the proper syntax for querying a COSMOS DB using the SQL API when dashes are used in the property name?

Error: Failed to query item for container appointment: {"code":400,"body":{"code":"BadRequest","message":"Gateway Failed to Retrieve Query Plan: Message: {"errors":[{"severity":"Error","location":{"start":7,"end":8},"code":"SC1001","message":"Syntax error, incorrect syntax near

This query works SELECT a.ID FROM accesspoint a

This query fails SELECT a.Point-Name FROM accesspoint a

What I've tried: I tried wrapping the value in double quotes, single quotes, (), <> Could not find any documentation on the use of dashes in the name

1
Did you try square brackets (SELECT a.[Point-Name]...). That's Microsoft's default quoting mechanism for SQL Server. Probably for CosmosDB as well(?)Bill Jetzer

1 Answers

5
votes

[] and quotes

SELECT * FROM c where c["point-name"] = "Eastern Standard Time"

Thank you Bill