Uredi

Deli z drugimi prek


fetch element

The root element of a FetchXml query.

Learn how to query data using FetchXml.

Example

<fetch>
  <entity name='account' />
</fetch>

Attributes

Name Required? Description
aggregate No Boolean value to specify that the query returns aggregate values. Learn about aggregating data
aggregatelimit No Set a limit below the standard 50,000 record aggregate limit. Learn about aggregate limits
count No Positive integer value to specify the number of records to return in a page. Learn about paging results
datasource No When using Dataverse long term data retention, set datasource to 'retained' to indicate the query is for retained rows only. Learn more about Dataverse long term data retention
distinct No Boolean value to specify that duplicate rows not be included in the results. Learn more about returning distinct results
latematerialize No Boolean value to direct the query to be broken up into smaller parts and reassemble the results before returning them. Using latematerialize might improve performance for some long-running queries. Learn more about using Late Materialize query.
no-lock No Legacy setting to prevent shared locks on records. No longer necessary.
options No A string value to apply one or more SQL optimizations. See Options
page No Positive integer value to specify the page number to return. Learn about paging results
paging-cookie No String value from a previous page of data to make retrieving the next page of data more efficient. Learn about paging results
returntotalrecordcount No Boolean value to specify whether the total number of records matching the criteria is returned. Learn how to count rows using FetchXml
top No Positive integer value to specify the number of records to return.
This value can't exceed 5,000.
Don't use top together with the page, count, or returntotalrecordcount attributes.
Learn more about limiting the number of rows
useraworderby No Boolean value to specify that choice column data sorting should Use Raw Order By mode. This sorts the choice options by the integer value. Without this, the default is to sort choice columns using the choice label values.

Child elements

Name Occurrences Description
entity 1 Specifies the child element for a fetch element, the 'parent entity' for the query. Only one entity is allowed.

Options

Important

Only apply these options when recommended by Microsoft technical support. Incorrect use of these options can damage the performance of a query.

Use these values with the options attribute to specify SQL Server hints to apply to the query. When more than one option is set, separate them by commas.

options='HashJoin,DisableRowGoal'
Query option SQL Server hint
ForceOrder Force Order
DisableRowGoal Hint: DISABLE_OPTIMIZER_ROWGOAL
EnableOptimizerHotfixes Hint: ENABLE_QUERY_OPTIMIZER_HOTFIXES
LoopJoin Loop Join
MergeJoin Merge Join
HashJoin Hash Join
NO_PERFORMANCE_SPOOL NO_PERFORMANCE_SPOOL
ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS Hint: ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS

More information: Hints (Transact-SQL) - Query