encode_sql_batch

Function encode_sql_batch 

Source
pub fn encode_sql_batch(sql: &str) -> Bytes
Expand description

Encode a SQL batch request with auto-commit (no explicit transaction).

The SQL batch packet payload includes:

  1. ALL_HEADERS section (required for TDS 7.2+)
  2. SQL text encoded as UTF-16LE

This function returns the encoded payload (without the packet header). For requests within an explicit transaction, use encode_sql_batch_with_transaction.

ยงExample

use tds_protocol::sql_batch::encode_sql_batch;

let sql = "SELECT * FROM users WHERE id = 1";
let payload = encode_sql_batch(sql);

// Payload includes ALL_HEADERS + UTF-16LE encoded SQL
assert!(!payload.is_empty());