mssql-value-serializer
Convert Rust values into SQL Server-compatible literal expressions, enabling dynamic SQL generation without parameter count limitations.
Prepared statements are commonly used to improve performance and security. By separating the SQL command from the data values, the database can cache execution plans and protect against SQL injection. Each variable passed to the query becomes a parameter, allowing safe reuse of the same statement with different values. However, because SQL Server enforces a strict 2100-parameter limit, queries that bind large collections of parameters—such as long IN lists or bulk inserts—can easily exceed this cap and trigger the too many parameters error.
Usage
use ;
let sql = format!;
assert_eq!;
let sql = format!;
assert_eq!;
Optional Features
serde: Implementsserde::Serializefor wrapper types, enabling SQL Server literal serialization behavior.chronoortime: Adds support for SQL Server date and time types.chronoandstable-local: If your local timezone does not observe daylight saving time (DST), enable this feature to use a fixed offset forDateTime<Local>, improving formatting performance.
rust_decimalorbigdecimal: Adds support for SQL Server decimal/numeric types.num-bigint: Adds support for SQL Server decimal/numeric types (only integers).
Crates.io
https://crates.io/crates/mssql-value-serializer
Documentation
https://docs.rs/mssql-value-serializer