Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/A-Point-Systems-ltd/ms-sql-mcp/llms.txt

Use this file to discover all available pages before exploring further.

UpdateData executes a single UPDATE statement against the connected SQL Server or Azure SQL Database. It is marked ReadOnly=false, Destructive=true in MCP metadata — agents should confirm intent with the user before calling it, particularly to verify the scope of rows that will be changed.
Always include a WHERE clause. A bare UPDATE table SET col = val without a WHERE clause updates every row in the table. Confirm the filter condition and expected row count with the user before executing.

Parameter

sql
string
required
A complete UPDATE T-SQL statement. A WHERE clause is strongly recommended to avoid full-table updates. Multi-batch scripts separated by GO are not supported. A trailing semicolon is allowed; an internal semicolon between two statements is rejected.

Return value

UpdateData returns a DbOperationResult with rowsAffected populated:
{
  "success": true,
  "error": null,
  "rowsAffected": 5
}
rowsAffected reflects the number of rows modified by the UPDATE statement, as returned by ExecuteNonQueryAsync. A result of 0 means no rows matched the WHERE clause — the statement succeeded but nothing changed. On failure:
{
  "success": false,
  "error": "The UPDATE statement conflicted with the FOREIGN KEY constraint \"FK_OrderLines_Orders\"."
}

AI Insights integration

On success, UpdateData calls QueueInsightDdlProcessing(), which enqueues the same background DDL audit drain and schema-fingerprint reconciliation used by all write tools. This is automatic when USE_INSIGHTS_LAYER is enabled (the default) and is a no-op when it is disabled. Because UPDATE does not change table schema, insight rows are rarely archived by a data-only update; the background job simply confirms no DDL drift has occurred since the last reconciliation.

Examples

UPDATE a single row by primary key

UPDATE dbo.Orders
SET    TotalAmount = 249.99,
       ShippedDate = '2024-06-15'
WHERE  OrderId = 1001;

UPDATE multiple rows with a range filter

UPDATE dbo.Products
SET    UnitPrice = UnitPrice * 1.10
WHERE  CategoryId = 3
  AND  Discontinued = 0;

UPDATE with a JOIN (SQL Server syntax)

UPDATE ol
SET    ol.UnitPrice = p.UnitPrice
FROM   dbo.OrderLines AS ol
JOIN   dbo.Products   AS p
    ON p.ProductId = ol.ProductId
WHERE  ol.OrderId = 1001;

UPDATE using a subquery filter

UPDATE dbo.Orders
SET    Status = 'Archived'
WHERE  OrderDate < (
           SELECT DATEADD(YEAR, -2, SYSUTCDATETIME())
       );
Before running a broad UPDATE, use ReadData with the equivalent SELECT … WHERE clause to preview exactly which rows will be affected and verify the row count matches your expectations.
SQL parameters are not supported — values must be embedded as literals. Never interpolate untrusted user input directly into the SQL string without sanitization. Doing so creates a SQL injection vulnerability.

Build docs developers (and LLMs) love