Optional. If set to true, this statement marks the end of the transaction.
The transaction should be committed or aborted after this statement
executes, and attempts to execute any other requests against this
transaction (including reads and queries) will be rejected.
For DML statements, setting this option may cause some error reporting to
be deferred until commit time (e.g. validation of unique constraints).
Given this, successful execution of a DML statement should not be assumed
until a subsequent Commit call completes successfully.
It is not always possible for Cloud Spanner to infer the right SQL type
from a JSON value. For example, values of type BYTES and values
of type STRING both appear in
[params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
In these cases, param_types can be used to specify the exact
SQL type for some or all of the SQL statement parameters. See the
definition of [Type][google.spanner.v1.Type] for more information
about SQL types.
Parameter names and values that bind to placeholders in the SQL string.
A parameter placeholder consists of the @ character followed by the
parameter name (for example, @firstName). Parameter names must conform
to the naming requirements of identifiers as specified at
https://cloud.google.com/spanner/docs/lexical#identifiers.
Parameters can appear anywhere that a literal value is expected. The same
parameter name can be used more than once, for example:
"WHERE id > @msg_id AND id < @msg_id + 100"
It is an error to execute a SQL statement with unbound parameters.
If present, results will be restricted to the specified partition
previously created using PartitionQuery(). There must be an exact
match for the values of fields common to this message and the
PartitionQueryRequest message used to create this partition_token.
Used to control the amount of debugging information returned in
[ResultSetStats][google.spanner.v1.ResultSetStats]. If
[partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
be set to
[QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
If this request is resuming a previously interrupted SQL statement
execution, resume_token should be copied from the last
[PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
interruption. Doing this enables the new SQL statement execution to resume
where the last one left off. The rest of the request parameters must
exactly match the request that yielded this token.
A per-transaction sequence number used to identify this request. This field
makes each request idempotent such that if the request is received multiple
times, at most one will succeed.
The sequence number must be monotonically increasing within the
transaction. If a request arrives for the first time with an out-of-order
sequence number, the transaction may be aborted. Replays of previously
handled requests will yield the same response as the first execution.
For queries, if none is provided, the default is a temporary read-only
transaction with strong concurrency.
Standard DML statements require a read-write transaction. To protect
against replays, single-use transactions are not supported. The caller
must either supply an existing transaction ID or begin a new transaction.
Partitioned DML requires an existing Partitioned DML transaction ID.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis document provides reference information for the \u003ccode\u003eExecuteSqlRequest\u003c/code\u003e class within the Google Cloud Spanner v1 API, detailing its properties, constructors, and inheritance.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eExecuteSqlRequest\u003c/code\u003e class is utilized for sending requests to execute SQL queries or streaming SQL operations, as defined by the \u003ccode\u003eExecuteSql\u003c/code\u003e and \u003ccode\u003eExecuteStreamingSql\u003c/code\u003e methods.\u003c/p\u003e\n"],["\u003cp\u003eThe class has multiple versions, with the latest being \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, alongside several older versions, including a range from \u003ccode\u003e3.5.0\u003c/code\u003e to \u003ccode\u003e4.6.0\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eKey properties of \u003ccode\u003eExecuteSqlRequest\u003c/code\u003e include \u003ccode\u003eSql\u003c/code\u003e for the query string, \u003ccode\u003eParams\u003c/code\u003e and \u003ccode\u003eParamTypes\u003c/code\u003e for SQL parameter binding, and \u003ccode\u003eTransaction\u003c/code\u003e to define the transaction to be used.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eExecuteSqlRequest\u003c/code\u003e implements several interfaces, such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, indicating its role within the protocol buffer ecosystem and .NET framework.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Class ExecuteSqlRequest (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.ExecuteSqlRequest) \n\n public sealed class ExecuteSqlRequest : IMessage\u003cExecuteSqlRequest\u003e, IEquatable\u003cExecuteSqlRequest\u003e, IDeepCloneable\u003cExecuteSqlRequest\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Spanner v1 API class ExecuteSqlRequest.\n\nThe request for \\[ExecuteSql\\]\\[google.spanner.v1.Spanner.ExecuteSql\\] and\n\\[ExecuteStreamingSql\\]\\[google.spanner.v1.Spanner.ExecuteStreamingSql\\]. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e ExecuteSqlRequest \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[ExecuteSqlRequest](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ExecuteSqlRequest), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[ExecuteSqlRequest](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ExecuteSqlRequest), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[ExecuteSqlRequest](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ExecuteSqlRequest), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nConstructors\n------------\n\n### ExecuteSqlRequest()\n\n public ExecuteSqlRequest()\n\n### ExecuteSqlRequest(ExecuteSqlRequest)\n\n public ExecuteSqlRequest(ExecuteSqlRequest other)\n\nProperties\n----------\n\n### DataBoostEnabled\n\n public bool DataBoostEnabled { get; set; }\n\nIf this is for a partitioned query and this field is set to `true`, the\nrequest is executed with Spanner Data Boost independent compute resources.\n\nIf the field is set to `true` but the request does not set\n`partition_token`, the API returns an `INVALID_ARGUMENT` error.\n\n### DirectedReadOptions\n\n public DirectedReadOptions DirectedReadOptions { get; set; }\n\nDirected read options for this request.\n\n### LastStatement\n\n public bool LastStatement { get; set; }\n\nOptional. If set to true, this statement marks the end of the transaction.\nThe transaction should be committed or aborted after this statement\nexecutes, and attempts to execute any other requests against this\ntransaction (including reads and queries) will be rejected.\n\nFor DML statements, setting this option may cause some error reporting to\nbe deferred until commit time (e.g. validation of unique constraints).\nGiven this, successful execution of a DML statement should not be assumed\nuntil a subsequent Commit call completes successfully.\n\n### ParamTypes\n\n public MapField\u003cstring, Type\u003e ParamTypes { get; }\n\nIt is not always possible for Cloud Spanner to infer the right SQL type\nfrom a JSON value. For example, values of type `BYTES` and values\nof type `STRING` both appear in\n\\[params\\]\\[google.spanner.v1.ExecuteSqlRequest.params\\] as JSON strings.\n\nIn these cases, `param_types` can be used to specify the exact\nSQL type for some or all of the SQL statement parameters. See the\ndefinition of \\[Type\\]\\[google.spanner.v1.Type\\] for more information\nabout SQL types.\n\n### Params\n\n public Struct Params { get; set; }\n\nParameter names and values that bind to placeholders in the SQL string.\n\nA parameter placeholder consists of the `@` character followed by the\nparameter name (for example, `@firstName`). Parameter names must conform\nto the naming requirements of identifiers as specified at\n\u003chttps://cloud.google.com/spanner/docs/lexical#identifiers\u003e.\n\nParameters can appear anywhere that a literal value is expected. The same\nparameter name can be used more than once, for example:\n\n`\"WHERE id \u003e @msg_id AND id \u003c @msg_id + 100\"`\n\nIt is an error to execute a SQL statement with unbound parameters.\n\n### PartitionToken\n\n public ByteString PartitionToken { get; set; }\n\nIf present, results will be restricted to the specified partition\npreviously created using PartitionQuery(). There must be an exact\nmatch for the values of fields common to this message and the\nPartitionQueryRequest message used to create this partition_token.\n\n### QueryMode\n\n public ExecuteSqlRequest.Types.QueryMode QueryMode { get; set; }\n\nUsed to control the amount of debugging information returned in\n\\[ResultSetStats\\]\\[google.spanner.v1.ResultSetStats\\]. If\n\\[partition_token\\]\\[google.spanner.v1.ExecuteSqlRequest.partition_token\\] is\nset, \\[query_mode\\]\\[google.spanner.v1.ExecuteSqlRequest.query_mode\\] can only\nbe set to\n\\[QueryMode.NORMAL\\]\\[google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL\\].\n\n### QueryOptions\n\n public ExecuteSqlRequest.Types.QueryOptions QueryOptions { get; set; }\n\nQuery optimizer configuration to use for the given query.\n\n### RequestOptions\n\n public RequestOptions RequestOptions { get; set; }\n\nCommon options for this request.\n\n### ResumeToken\n\n public ByteString ResumeToken { get; set; }\n\nIf this request is resuming a previously interrupted SQL statement\nexecution, `resume_token` should be copied from the last\n\\[PartialResultSet\\]\\[google.spanner.v1.PartialResultSet\\] yielded before the\ninterruption. Doing this enables the new SQL statement execution to resume\nwhere the last one left off. The rest of the request parameters must\nexactly match the request that yielded this token.\n\n### Seqno\n\n public long Seqno { get; set; }\n\nA per-transaction sequence number used to identify this request. This field\nmakes each request idempotent such that if the request is received multiple\ntimes, at most one will succeed.\n\nThe sequence number must be monotonically increasing within the\ntransaction. If a request arrives for the first time with an out-of-order\nsequence number, the transaction may be aborted. Replays of previously\nhandled requests will yield the same response as the first execution.\n\nRequired for DML statements. Ignored for queries.\n\n### Session\n\n public string Session { get; set; }\n\nRequired. The session in which the SQL query should be performed.\n\n### SessionAsSessionName\n\n public SessionName SessionAsSessionName { get; set; }\n\n[SessionName](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.SessionName)-typed view over the [Session](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ExecuteSqlRequest#Google_Cloud_Spanner_V1_ExecuteSqlRequest_Session) resource name property.\n\n### Sql\n\n public string Sql { get; set; }\n\nRequired. The SQL string.\n\n### Transaction\n\n public TransactionSelector Transaction { get; set; }\n\nThe transaction to use.\n\nFor queries, if none is provided, the default is a temporary read-only\ntransaction with strong concurrency.\n\nStandard DML statements require a read-write transaction. To protect\nagainst replays, single-use transactions are not supported. The caller\nmust either supply an existing transaction ID or begin a new transaction.\n\nPartitioned DML requires an existing Partitioned DML transaction ID."]]