Investigate ODBC compatibility mode via environment variable
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
Research direction
Start by reviewing PR #638 and the listed differences between go-sqlcmd and ODBC sqlcmd. Compare codepage handling, output, errors, exit codes, variable expansion, nulls, and column widths, then determine which behaviors can be configured. Done requires a documented compatibility design, implementation scope, tests, and documentation updates.
Written by the indexing model from the issue text.
Description
Summary
Investigate adding an environment variable (e.g., SQLCMD_ODBC_COMPAT=1) that would make go-sqlcmd behave exactly like the original ODBC sqlcmd for maximum backward compatibility.
Motivation
go-sqlcmd has intentionally diverged from ODBC sqlcmd in several areas to provide better defaults for modern usage. However, users migrating existing scripts or workflows may need exact behavioral compatibility with the original tool.
Potential Scope
When the compatibility mode is enabled, go-sqlcmd would match ODBC sqlcmd behavior in areas including:
Codepage Handling (PR #638)
| Behavior | go-sqlcmd (current) | ODBC sqlcmd | Compat mode |
|---|---|---|---|
| Default encoding | UTF-8 | Windows ANSI (system locale) | ANSI |
| UTF-16 codepages (1200, 1201) | Not supported | Supported | Supported |
| BOM detection | Automatic | Automatic | Automatic |
Other Potential Areas (to investigate)
- Output formatting differences
- Error message formatting
- Exit code behavior
- Variable expansion edge cases
- Null handling in output
- Column width calculations
Implementation Options
- Single env var: SQLCMD_ODBC_COMPAT=1 enables all compatibility behaviors
- Granular env vars: SQLCMD_CODEPAGE_COMPAT=1, SQLCMD_OUTPUT_COMPAT=1, etc.
- Command-line flag: --odbc-compat or -y (if available)
Tasks
- Document all known behavioral differences between go-sqlcmd and ODBC sqlcmd
- Evaluate which differences can reasonably be made configurable
- Design the compatibility mode API (env var name, granularity)
- Implement compatibility mode for codepage handling
- Add tests for compatibility mode behavior
- Update documentation
Related
- PR #638: Add -f codepage flag for input/output encoding
- This issue originated from codepage investigation showing ODBC uses ANSI default vs go-sqlcmd's UTF-8 default
Labels
enhancement, documentation
- Dominant language
- Go
- Stars
- 595
- Forks
- 91
- Avg merge
- 9h 35m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/go-sqlcmd
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
All issues in microsoft/go-sqlcmd
Similar issues
-
textual definition
Difficulty 1/5 Under an hour Newbie friendliness 90/100
geneontology/go-ontology#32653 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
needs design
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Priority/High ready-for-agent Severity/Major Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100