Microsoft MSSQL Block
Execute SQL queries and manage files in Microsoft SQL Server
The Microsoft MSSQL block connects to a Microsoft SQL Server instance to execute T-SQL queries, manage data (insert/update/delete), and perform file operations. Use it when a workflow needs to read from or write to a SQL Server database with secure connections, automatic query parameterization, and connection pooling.
Overview
| Property | Value |
|---|---|
| Type | mssql |
| Category | tools |
| Color | #CC2927 |
When to Use
- Run ad-hoc T-SQL
SELECTqueries against a SQL Server database and pipe results into downstream blocks. - Insert new records into a table from data produced earlier in the workflow (single row or batch).
- Update existing rows using JSON-defined field values and WHERE conditions.
- Delete rows that match specific conditions without writing raw SQL.
- Create, read, edit, delete, or list files associated with the SQL Server host (e.g., scripts, config files).
- Connect to on-premises or cloud SQL Server over SSL/TLS, including environments that use self-signed certificates.
Configuration
Server
Required. The SQL Server hostname or IP address (e.g. localhost or server.domain.com). Accepts {{...}} references.
Port
SQL Server port. Defaults to 1433. Override only when the instance listens on a non-standard port.
Database
Required. The target database name (e.g. MyDatabase).
Username
Required. The SQL Server login name (e.g. sa or domain\user).
Password
Required. The database password. Store secrets as environment variables and reference them with {{ENV_VAR_NAME}} (e.g. {{MSSQL_PASSWORD}}).
Enable SSL Encryption
Toggle (switch). Enables SSL/TLS encryption for the connection. Defaults to true in the underlying tool.
Trust Server Certificate
Toggle (switch). When enabled, the driver accepts self-signed certificates without validation. Defaults to false.
Action
Required. Dropdown that selects the operation to perform. Defaults to execute. Options:
| Label | ID | Required additional fields |
|---|---|---|
| Execute Query | execute | query |
| Insert Data | insert | table, data |
| Update Data | update | table, data, conditions |
| Delete Data | delete | table, conditions |
| Create File | create_file | filePath, content |
| Get File | get_file | filePath |
| Edit File | edit_file | filePath, content |
| Delete File | delete_file | filePath |
| List Files | list_files | folderPath (optional) |
SQL Query
Visible when action = execute. The T-SQL statement to run (e.g. SELECT * FROM Users WHERE active = 1). Supports AI-assisted generation via the wand icon. Reference prior block outputs with {{blockName.output.fieldName}} and workflow variables with {{variable.variableName}}.
Table Name
Visible when action is insert, update, or delete. Required for those actions. The name of the target table (e.g. Users, Products).
Data
Visible when action is insert or update. Required for those actions. A JSON object (or array of objects) containing the field values to write. Example: {"name": "John Doe", "email": "john@example.com", "active": true}. Supports AI-assisted generation.
Conditions (WHERE clause)
Visible when action is update or delete. Required for those actions. A JSON object defining the WHERE conditions (e.g. {"id": 123} or {"status": "active"}).
File Path
Visible when action is create_file, get_file, edit_file, or delete_file. Required for those actions. Path to the target file (e.g. scripts/backup.sql).
File Content
Visible when action is create_file or edit_file. Required for those actions. The content to write into the file.
Folder Path
Visible when action = list_files. Optional. The folder to list files from (e.g. scripts/). Leave empty to list from the root.
Inputs & Outputs
Inputs:
server(string) — SQL Server hostname or IPport(number) — SQL Server portdatabase(string) — Database nameusername(string) — Database usernamepassword(string) — Database passwordencrypt(boolean) — Enable SSL encryptiontrustServerCertificate(boolean) — Trust server certificateaction(string) — Operation to performquery(string) — SQL query to executetable(string) — Table name for operationsdata(json) — Data for insert/update operationsconditions(json) — WHERE conditions for update/deletefilePath(string) — File path for file operationscontent(string) — File contentfolderPath(string) — Folder path for listing files
Outputs:
data(json) — Query results for SELECT operationsaffectedRows(number) — Number of rows affected by INSERT/UPDATE/DELETE operationsmetadata(json) — Query execution metadata including timing and row countsfileName(string) — Name of the file for file operationsfilePath(string) — Full path of the filecontent(string) — File content for get/edit operationsfiles(json) — List of files and folders for list operationserror(string) — Error message if operation failserrorDetails(json) — Detailed error information including type and execution time
Tools
Microsoft SQL Server (mssql_database) — Executes SQL queries and manages files in a Microsoft SQL Server database. Dispatches to the /api/tools/mssql endpoint using connection parameters, the selected action, and any action-specific inputs. Handles all nine operations: execute, insert, update, delete, create_file, get_file, edit_file, delete_file, and list_files. Uses connection pooling (up to 10 connections per host) with parameterized queries to prevent SQL injection.
YAML Example
mssql_1:
type: mssql
name: "Microsoft MSSQL"
inputs:
server: "localhost"
port: 1433
database: "MyDatabase"
username: "sa"
password: "{{MSSQL_PASSWORD}}"
encrypt: true
trustServerCertificate: false
action: "execute"
query: "SELECT * FROM Users WHERE active = 1"
connections:
outgoing:
- target: next-block-id