A native Windows desktop app that converts C# interpolated SQL strings into plain SQL ready to paste into any query window
Paste a C# interpolated SQL string — the kind you'd find in a .NET repository using Dapper or ADO.NET — and the app will:
- Detect
{(int)Enum.Value}cast expressions and let you fill in the integer value (or auto-fill by pasting the enum definition) - Detect
{(condition ? "SQL fragment" : "")}ternary expressions, group them by their boolean variable, and let you picktrue/falsefrom a dropdown - Detect
@paramNameSQL parameters and let you type replacement values inline — list parameters (used afterIN) auto-wrap1,2,3→(1,2,3) - Detect
OPENJSON(@paramName) WITH (...)JSON parameters and provide a dedicated input
- .NET 8 SDK
- Windows (WPF app)
git clone https://github.com/tompet0191/replace-values-sql.git
cd replace-values-sql
dotnet runOr publish an executable:
dotnet publish -c Release --self-contained falseThe executable will be in bin\Release\net8.0-windows\publish\.
- Paste your C# interpolated SQL into the top-left box (the
$@"..."wrapper is stripped automatically) - Click Parse Query (
Ctrl+Enter) - Optionally paste C# enum definitions into the bottom-left box and click Apply Enums to auto-fill cast expression values
- Fill in the parameter values on the right — greyed-out rows won't appear in the output
- Click Generate SQL (
Ctrl+Shift+Enter) - Click Copy to Clipboard and paste into query window
When the query contains OPENJSON(@param) WITH (...), the app reads the column definitions from the WITH clause and shows a dedicated input with two modes — toggle between them using the Table / Paste JSON buttons on the parameter row:
- Table mode — an editable grid with one column per
WITHfield. Add rows with + Add Row, remove individual rows with ✕. The app serialises the grid into a JSON array and wraps it in SQL single quotes when generating. - Paste JSON mode — paste a raw JSON value directly (object
{...}for a single row, array[{...}, {...}]for multiple rows). The value is passed through as-is, wrapped in SQL single quotes.