Home > Net >  Azure Cosmos DB Stored Procedure | Select and Return Multiple Documents Without Partition Id Value
Azure Cosmos DB Stored Procedure | Select and Return Multiple Documents Without Partition Id Value

Time:02-22

I want to select top N documents from container by stored procedure. But it forces you to give a partition id value. But my query doesn't depend on partition id, I don't even use WHERE clause. My query:

SELECT TOP 100 * FROM Clans ORDER BY Clans.whp DESC

How can I omit partition id value? Or shouldn't I use stored procedures? I know I can make a SQL query request by Cosmos DB SDK.

CodePudding user response:

How can I omit partition id value?

You can't. Stored procedure executions are always scoped to a logical partition i.e. you will need to specify a partition key value.

Or shouldn't I use stored procedures? I know I can make a SQL query request by Cosmos DB SDK.

That would work. You can always do a cross-partition query through your code. Please do note that it may be an expensive query causing you to consume more RUs.

  • Related