Skip to content

EXEC queries

Mark Carrington edited this page Nov 5, 2024 · 3 revisions

SQL 4 CDS translates EXEC queries to execute a built-in message or custom action or custom API using stored procedure syntax.

The supported syntax is the same as SQL Server with the exception that the OUTPUT clause is not supported.

Not all messages, custom actions or custom APIs are supported. To be able to be invoked as a stored procedure, all request fields for the message (represented as input parameters to the stored procedure) must be scalar values (except for a single PagingInfo parameter if the output is an entity collection), and the response fields (if any) must be either:

  1. A single field of an entity-derived type, or
  2. A single field of an entity collection, or
  3. A single field of an array of a scalar type, or
  4. Any number of fields of a scalar type

If there is an entity type output parameter but the message metadata does not identify what type that entity will be, it will be returned as a JSON-formatted string. Otherwise, a column will be included in the output for each column defined for that entity type.

Examples

WhoAmI

DECLARE @UserId UNIQUEIDENTIFIER
EXEC WhoAmI @UserId = @UserId OUTPUT

SELECT @UserId
Clone this wiki locally