MssqlClient
Microsoft SQL Server client implementation for Effect SQL, backed by the tedious driver.
This module provides the MssqlClient service, constructors, layers, and SQL Server statement compiler. make creates a pooled Tedious client, checks the connection with SELECT 1, maps SQL Server failures to SqlError, and supports transactions with savepoints. The SQL Server-specific service adds typed Tedious parameters with param, stored procedure calls with call, direct or config-backed layers, and default parameter type mappings. Streaming queries are not implemented by this driver.
Constants
defaultParameterTypes
Signature
declare const defaultParameterTypes: Record<Statement.PrimitiveKind, DataType>;Constructors
Creates a scoped Microsoft SQL Server client backed by a connection pool, with transaction and stored procedure support. Streaming queries are not implemented.
Signature
declare function make(
options: MssqlClientConfig,
): Effect<MssqlClient, SqlError, Scope | Reactivity>;makeCompiler
Creates the SQL Server statement compiler, using @1-style placeholders, bracket-escaped identifiers, and SQL Server OUTPUT INSERTED returning clauses.
Signature
declare function makeCompiler(transform?: (_: string) => string): Compiler;Layers
Creates a layer from a concrete SQL Server client configuration, providing both MssqlClient and SqlClient.
Signature
declare function layer(config: MssqlClientConfig): Layer<MssqlClient | SqlClient, SqlError>;layerConfig
Creates a layer from a Config-wrapped SQL Server client configuration, providing both MssqlClient and SqlClient.
Signature
declare const layerConfig: (
config: Config.Wrap<MssqlClientConfig>,
) => Layer.Layer<Client.SqlClient | MssqlClient, Config.ConfigError | SqlError>;Models
MssqlClientConfig interface
Configuration for a Microsoft SQL Server client, including connection, authentication, pool, parameter type, span attribute, and query/result name transform options.
Signature
interface MssqlClientConfig {
readonly authType?: string;
readonly cancelTimeout?: Input;
readonly connectionRetryInterval?: Input;
readonly connectionTTL?: Input;
readonly connectTimeout?: Input;
readonly database?: string;
readonly domain?: string;
readonly encrypt?: boolean;
readonly instanceName?: string;
readonly maxConnections?: number;
readonly maxRetriesOnTransientErrors?: number;
readonly minConnections?: number;
readonly multiSubnetFailover?: boolean;
readonly parameterTypes?: Record<PrimitiveKind, DataType>;
readonly password?: Redacted<string>;
readonly port?: number;
readonly server: string;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
readonly trustServer?: boolean;
readonly username?: string;
}Services
MssqlClient
Service tag for the Microsoft SQL Server client service.
When to use
Use to access or provide a Microsoft SQL Server client through the Effect context.
Signature
declare const MssqlClient: Service<MssqlClient, MssqlClient>;MssqlClient interface
Microsoft SQL Server client service, extending SqlClient with typed parameter fragments and stored procedure calls.
Signature
interface MssqlClient extends SqlClient {
<A extends object = Row>(strings: TemplateStringsArray, ...args: Array<any>): Statement<A>;
(value: string): Identifier;
readonly [TypeId]: typeof TypeId;
readonly call: <
I extends Record<string, Parameter<any>>,
O extends Record<string, Parameter<any>>,
A extends object,
>(
procedure: ProcedureWithValues<I, O, A>,
) => Effect<Result<O, A>, SqlError>;
readonly config: MssqlClientConfig;
readonly param: (type: DataType, value: unknown, options?: any) => Fragment;
}
Default mapping from Effect SQL primitive value kinds to Tedious SQL Server parameter data types.