Endpoint Query documents using Cosmos DB SQL query language
Name
query_documents
Description
Gets data based on the specified SQL query. [API reference]
Parameters
Parameter | Required | Options | ||||||
---|---|---|---|---|---|---|---|---|
Name:
Label: Table Name (Case-Sensitive) |
YES | |||||||
Name:
Label: SQL Query Query for Cosmos DB |
YES | |||||||
Name:
Label: Database Name (keep blank to use default) Case-Sensitive Leave blank to use default DB set on connection screen |
||||||||
Name:
Label: Allow Query Scan |
|
|||||||
Name:
Label: Allow Cross Partition Query |
|
|||||||
Name:
Label: Cross Partition Key Range Id |
||||||||
Name:
Label: Max Rows Per Page (Adjust for Speed) An integer indicating the maximum number of items to be returned per page. |
Output Columns
Label | Data Type (SSIS) | Data Type (SQL) | Length | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime. |
Input Columns
Label | Data Type (SSIS) | Data Type (SQL) | Length | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime. |
Examples
SSIS
Use Cosmos DB Connector in API Source or in API Destination SSIS Data Flow components to read or write data.
API Source
Required Parameters | |
---|---|
Table Name (Case-Sensitive) | Fill-in the parameter... |
SQL Query | Fill-in the parameter... |
Filter | Fill-in the parameter... |
Optional Parameters | |
Database Name (keep blank to use default) Case-Sensitive | |
Allow Query Scan | true |
Allow Cross Partition Query | true |
Cross Partition Key Range Id | 0 |

API Destination
Required Parameters | |
---|---|
Table Name (Case-Sensitive) | Fill-in the parameter... |
SQL Query | Fill-in the parameter... |
Filter | Fill-in the parameter... |
Optional Parameters | |
Database Name (keep blank to use default) Case-Sensitive | |
Allow Query Scan | true |
Allow Cross Partition Query | true |
Cross Partition Key Range Id | 0 |

ODBC application
Use these SQL queries in your ODBC application data source:
Query Documents from Cosmos DB Table (Container) using SQL
Lists all users Cosmos DB Database
SELECT *
FROM query_documents
WITH(
-- Database='TestDB', --if you dont supply connection level Default Database name is used
Table='TestContainer',
Query='select * from root Where root.id!=null order by root._ts desc',
Meta='id:string(50);name:string(50);city;age'
--Meta='id; name; city; age' -- no types at all. Default is string(2000)
--Meta='id; name:string(50); city; age: int' --Mixed types. If type is missing default string(2000) used
--check below URL for more information on Qyery Language Syntax
--https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/select
)
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Query Documents from Cosmos DB Table (Container) using SQL
Lists all users Cosmos DB Database
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM query_documents
WITH(
-- Database=''TestDB'', --if you dont supply connection level Default Database name is used
Table=''TestContainer'',
Query=''select * from root Where root.id!=null order by root._ts desc'',
Meta=''id:string(50);name:string(50);city;age''
--Meta=''id; name; city; age'' -- no types at all. Default is string(2000)
--Meta=''id; name:string(50); city; age: int'' --Mixed types. If type is missing default string(2000) used
--check below URL for more information on Qyery Language Syntax
--https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/select
)';
EXEC (@MyQuery) AT [LS_TO_COSMOS_DB_IN_GATEWAY];