title: Is it possible to use a parameter to for a nested object property key in Cosmos DB SQL
body: <p>Given objects with a nested object</p>
  <pre><code>{
    &quot;id&quot;: &quot;D1&quot;,
    &quot;resourceType&quot;: &quot;shape&quot;,
    &quot;metadata&quot;: {
      &quot;color&quot;: &quot;red&quot;,
      &quot;size&quot;: &quot;small&quot;,
      &quot;how heavy&quot;: &quot;very&quot;
    }
  </code></pre>
  <p>...it's possible to query them (in this case <code>metadata</code>) using the <code>[]</code> syntax by using a literal:</p>
  <pre><code>SELECT r.id, r.resourceType, r.metadata FROM Resources r WHERE r.metadata['color'] = @v1
  </code></pre>
  <p>Is it possible to parametrize the property access of <code>metadata</code>? The following doesn't work.</p>
  <pre><code>SELECT r.id, r.resourceType, r.metadata FROM Resources r WHERE r.metadata[@k1] = @v1
  </code></pre>
  <p>The preceding query produces an error</p>
  <pre><code>Syntax error, incorrect syntax near '@k1'.
  </code></pre>
  <p>The official docs <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-parameterized-queries" rel="nofollow noreferrer">Parameterized queries in Azure Cosmos DB</a> currently show only very simple examples.</p>
  <p>Is there another way to achieve this?</p>