AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/servicecontrol/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

ServiceControl SQL Server Storage

Component:
ServiceControl

From ServiceControl 7, Error and Audit instances can use SQL Server instead of RavenDB storage. Select SQL Server when an instance should use an existing SQL Server deployment. Storage is configured separately for each instance.

Supported SQL Server versions

ServiceControl supports the SQL Server versions that are in mainstream support; see the SQL Server lifecycle. Full-Text Search must be installed; see Prepare the database.

Prepare the database

Create a database before configuring the instance as ServiceControl does not create the database. Setup creates the instance's schema if it does not exist. If the identity that runs setup cannot create schemas, create the schema in advance and grant that identity rights on it. Error and Audit instances can use the same database but not the same schema; see sharing a database.

Message body search is always enabled for SQL Server storage, regardless of the EnableFullTextSearchOnBodies setting.

Database permissions

Grant each identity the following rights on the instance's database:

IdentityRequired rights
The identity that runs setupMembership in db_ddladmin, db_datareader, and db_datawriter, or in db_owner. Setup creates the schema, tables, indexes, and the full-text catalog and index, and records the applied migrations.
The identity the instance runs asMembership in db_datareader and db_datawriter, or SELECT, INSERT, UPDATE, and DELETE on the instance's schema. Normal operation does not change the schema.

When the same connection string is used for setup and normal operation, as the ServiceControl Management Utility and PowerShell do, that identity needs the setup rights.

Authentication

Configure database authentication in the connection string for each Error or Audit instance. This is separate from the transport connection string.

ServiceControl uses Microsoft.Data.SqlClient. Microsoft Entra ID authentication is supported via the standard connection string options, including managed identity and service principal authentication.

Choose an authentication method suitable for an unattended service. Ensure the selected identity is available to the ServiceControl host and has the database permissions required for setup and normal operation.

Error instance configuration

Set the storage type to SQLServer, provide the database connection string, and configure the retention period. Also configure an external message body store, which is required even if most bodies fit inline in the database. The ServiceControl Management Utility and the PowerShell module configure it when they create the instance. For manual or container deployments, add the ServiceControl/MessageBody/* settings to the instance's configuration file or environment.

ServiceControl/StorageType

Added in version 7.0.0

The storage implementation used by the instance. This setting is required; an instance without it does not start.

ContextName
Environment variableSERVICECONTROL_STORAGETYPE
App config keyServiceControl/StorageType
SCMU fieldSTORAGE TYPE
TypeDefault value
stringNone (required)

Valid values are RavenDB, SQLServer, and PostgreSQL. To choose where message bodies are stored with SQL Server or PostgreSQL storage, use ServiceControl/MessageBody/StorageType.

ServiceControl/Database/ConnectionString

Added in version 7.0.0

The connection string for the SQL Server or PostgreSQL database. The database must already exist.

ContextName
Environment variableSERVICECONTROL_DATABASE_CONNECTIONSTRING
App config keyServiceControl/Database/ConnectionString
SCMU fieldDATABASE CONNECTION STRING
TypeDefault value
stringNone (required for SQL Server and PostgreSQL storage)

ServiceControl/Database/Schema

Added in version 7.0.0

The schema that contains the Error instance tables. If the schema does not exist, setup creates it, which requires permission to create schemas. Changing this setting does not move existing data; an instance that already has data must keep using the schema that contains it.

ContextName
Environment variableSERVICECONTROL_DATABASE_SCHEMA
App config keyServiceControl/Database/Schema
SCMU fieldN/A
TypeDefault value
stringNone. Tables are created in the connection's default schema: the login's default schema on SQL Server (usually dbo), or the current schema from search_path on PostgreSQL (usually public).

ServiceControl/ErrorRetentionPeriod

The grace period that errored messages are kept before they are deleted.

For a message to be considered for deletion, it needs to have a status of either Archived, RetryIssued, or Resolved.

ContextName
Environment variableSERVICECONTROL_ERRORRETENTIONPERIOD
App config keyServiceControl/ErrorRetentionPeriod
SCMU fieldERROR RETENTION PERIOD
TypeDefault value
timespanNone (required) (SCMU slider defaults to 15 Days)

Valid range for this setting is between 5 days and 45 days.

Set these variables in the Error instance's environment to use file system body storage. Replace the connection string placeholder with credentials supplied by the deployment environment. These storage settings supplement the instance's transport and other required settings.

SERVICECONTROL_STORAGETYPE=SQLServer
SERVICECONTROL_DATABASE_CONNECTIONSTRING="Server=sqlserver;Database=ServiceControl;User Id=sc;Password=..."
SERVICECONTROL_MESSAGEBODY_STORAGETYPE=FileSystem
SERVICECONTROL_MESSAGEBODY_FILESYSTEM_STORAGEPATH=/var/servicecontrol/bodies
SERVICECONTROL_ERRORRETENTIONPERIOD=15

See the Error instance settings reference for the complete reference.

To share the ingestion load across several processes, see Scaling out error ingestion. Workers use this instance's database, schema, and message body store, and only this instance runs setup.

Audit instance configuration

Set the storage type to SQLServer, provide the database connection string, and configure the retention period. Also configure an external message body store, which is required even if most bodies fit inline in the database. The ServiceControl Management Utility and the PowerShell module configure it when they create the instance. For manual or container deployments, add the ServiceControl.Audit/MessageBody/* settings to the instance's configuration file or environment.

ServiceControl.Audit/StorageType

Added in version 7.0.0

The storage implementation used by the Audit instance. This setting is required; an instance without it does not start.

ContextName
Environment variableSERVICECONTROL_AUDIT_STORAGETYPE
App config keyServiceControl.Audit/StorageType
SCMU fieldSTORAGE TYPE
TypeDefault value
stringNone (required)

Valid values are RavenDB, SQLServer, and PostgreSQL. To choose where message bodies are stored with SQL Server or PostgreSQL storage, use ServiceControl.Audit/MessageBody/StorageType.

ServiceControl.Audit/Database/ConnectionString

Added in version 7.0.0

The connection string for the SQL Server or PostgreSQL database. The database must already exist.

ContextName
Environment variableSERVICECONTROL_AUDIT_DATABASE_CONNECTIONSTRING
App config keyServiceControl.Audit/Database/ConnectionString
SCMU fieldDATABASE CONNECTION STRING
TypeDefault value
stringNone (required for SQL Server and PostgreSQL storage)

ServiceControl.Audit/Database/Schema

Added in version 7.0.0

The schema that contains the Audit instance tables. If the schema does not exist, setup creates it, which requires permission to create schemas. Changing this setting does not move existing data; an instance that already has data must keep using the schema that contains it.

ContextName
Environment variableSERVICECONTROL_AUDIT_DATABASE_SCHEMA
App config keyServiceControl.Audit/Database/Schema
SCMU fieldN/A
TypeDefault value
stringsc_audit

ServiceControl.Audit/AuditRetentionPeriod

The grace period to keep an audit message before it is deleted.

ContextName
Environment variableSERVICECONTROL_AUDIT_AUDITRETENTIONPERIOD
App config keyServiceControl.Audit/AuditRetentionPeriod
SCMU fieldAUDIT RETENTION PERIOD
TypeDefault value
timespanNone (required)

Valid range for this setting is from 1 hour to 365 days.

ServiceControl.Audit/MaxBodySizeToStore

A size limit, in bytes, for message bodies. Its effect depends on the storage type:

StorageEffect
RavenDBThe largest message body that the Audit instance stores. Larger bodies cannot be viewed in ServicePulse.
SQL Server or PostgreSQLThe largest text message body that is stored inline in the database. Larger text bodies, and bodies that are not text, are stored in the external message body store and can be viewed in ServicePulse. A larger text body also keeps its first MaxBodySizeToStore bytes in the database for full-text search. See what is stored where.
ContextName
Environment variableSERVICECONTROL_AUDIT_MAXBODYSIZETOSTORE
App config keyServiceControl.Audit/MaxBodySizeToStore
SCMU fieldN/A
TypeDefault value
int102400 (100 KB)

Example environment variables for an Audit instance using file system body storage:

SERVICECONTROL_AUDIT_STORAGETYPE=SQLServer
SERVICECONTROL_AUDIT_DATABASE_CONNECTIONSTRING="Server=sqlserver;Database=ServiceControl.Audit;User Id=sc;Password=..."
SERVICECONTROL_AUDIT_MESSAGEBODY_STORAGETYPE=FileSystem
SERVICECONTROL_AUDIT_MESSAGEBODY_FILESYSTEM_STORAGEPATH=/var/servicecontrol/audit-bodies
SERVICECONTROL_AUDIT_AUDITRETENTIONPERIOD=30

See the Audit instance settings reference for the complete reference.

Run setup

Setup applies database migrations for both Error and Audit instances. Setup also provisions the external message body store. See database permissions for the rights setup and normal operation need. See the Error container setup or Audit container setup instructions when deploying in containers.

The ServiceControl Management Utility (SCMU) and the PowerShell module run setup when they create or upgrade an instance, and can create SQL Server-backed Error and Audit instances:

  • SCMU: choose SQL Server as the STORAGE TYPE, enter the DATABASE CONNECTION STRING, and check the MESSAGE BODY PATH, which defaults to %ProgramData%\Particular\ServiceControl\<instance name>\MessageBodies. SCMU stores message bodies only on the file system.
  • PowerShell: pass -StorageType SQLServer and -DatabaseConnectionString to New-ServiceControlInstance or New-ServiceControlAuditInstance, and leave out -DBPath and -DatabaseMaintenancePort, which apply only to RavenDB. Also pass -MessageBodyPath, or choose Azure Blob Storage or Amazon S3 with -MessageBodyStorageType. See the Error instance and Audit instance PowerShell guides.

To change the message body store after the instance is created, change the message body settings in the instance's configuration file. Bodies already stored are not moved, so make the change before the instance ingests messages.

Neither tool sets Database/Schema, so instances they create use the default schema. Two Audit instances in one database both use the sc_audit schema, and two Error instances that connect with the same login both use that login's default schema, so they share tables. Create independent instances of the same type in separate databases. To share a database between Audit instances on purpose, see Scaling out audit ingestion; those instances must also share a message body store. An Error instance and an Audit instance can use one database, because their default schemas differ.

Verify the setup

Setup logs SQL Server database migration completed for an Error instance, or Audit database migration completed for an Audit instance, and exits without an error. After the instance starts, check that no storage custom checks report a failure in ServicePulse.

Troubleshooting

  • Setup fails with "ServiceControl requires the SQL Server Full-Text Search feature": install Full-Text Search on the server, then run setup again.
  • Setup fails with a permission error: grant the rights in database permissions, or create the schema in advance.
  • Setup fails because "A primary instance and an audit instance cannot share a schema": set a different Database/Schema for one of the instances. See sharing a database.
  • The instance does not start with "Maintenance mode is not supported": set MaintenanceMode to false. Maintenance mode is only available with embedded RavenDB storage. To perform database maintenance, stop the ServiceControl instance and access SQL Server directly.
  • The ServiceControl Retention custom check fails: check the instance log. A body store that refuses deletes stops failed-message retention; see external message body storage operations.
  • Messages show without their bodies after a restore: restore the database and the external message body store from the same point in time. See backup and restore.

Next steps