microsoft / microsoft/go-sqlcmd

Inconsistent Float Formatting Between go-sqlcmd and ODBC SQLCMD Versions

Open
#555 7 comments 1 reaction 2 assignees View on GitHub

@dlevy-msft-sql is already working on this.

Since Jan 31, 2026.

Dominant language
Go
Stars
595
Forks
91
Avg merge
9h 35m
Merged PRs (30d)
1

Description

Description
In Windows OS the go-sqlcmd application produces a different output format for FLOAT data types compared to the ODBC-based SQLCMD.EXE when executing the same SQL query. This discrepancy can cause issues for applications and scripts that rely on consistent float formatting.

Steps to Reproduce
  1. Create the following table:
CREATE TABLE [dbo].[Point](
   [PointId] [int] NOT NULL,
   [SessionId] [int] NULL,
   [Longitude] [float] NOT NULL,
   [Latitude] [float] NOT NULL,
CONSTRAINT [PK_Point] PRIMARY KEY CLUSTERED 
(
    [PointId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT INTO [dbo].[Point] ([PointId], [SessionId], [Longitude], [Latitude]) VALUES 
  (1, 3, 788991.19988463481, 4713347.3103808956),
  (2, 3, 789288.40771771886, 4712632.075629076),
  (3, 3, 788569.36558582436, 4714608.0418091472);
GO
  1. Execute the following query using go-sqlcmd (version 1.8.1):
sqlCmd.exe -S serverName -d dbname -U username -P password -Q "SELECT TOP 10 * FROM dbo.Point" -s";" -W
  1. Execute the same query using the ODBC SQLCMD (version 15.0.4410):
sqlCmd.exe -S serverName -d dbname -U username -P password -Q "SELECT TOP 10 * FROM dbo.Point" -s";" -W
Observed Behavior

go-sqlcmd Output:

PointId;SessionId;Longitude;Latitude
-------;---------;---------;--------
1;3;788991.1998846348;4.713347310380896e+06
2;3;789288.4077177189;4.712632075629076e+06
3;3;788569.3655858244;4.714608041809147e+06

ODBC SQLCMD Output:

PointId;SessionId;Longitude;Latitude
-------;---------;---------;--------
1;3;788991.19988463481;4713347.3103808956
2;3;789288.40771771886;4712632.075629076
3;3;788569.36558582436;4714608.0418091472
Expected Behavior

The float formatting in the output of go-sqlcmd should align with the behavior of the ODBC SQLCMD to maintain compatibility and consistency across different SQLCMD implementations.

Environment
  • go-sqlcmd version: 1.8.1
  • ODBC sqlcmd version: 15.0.4410
  • Database Server: SQL Server 2019, SQL Server 2022
  • Operating System: Windows 11, Windows server
Additional Information

This issue primarily affects the formatting of float numbers. For example:

  • In go-sqlcmd, 4.713347310380896e+06
  • In ODBC sqlcmd, 4713347.3103808956

The scientific notation output from go-sqlcmd is less intuitive and might require additional parsing in downstream applications.

Request

Please investigate this behavior and consider aligning the float formatting of go-sqlcmd with the output of the ODBC-based SQLCMD.EXE.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.