-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
Description
When executing a query that returns no results, go-sqlcmd does not include the column headers in the output, unlike the ODBC-based SQLCMD.EXE. This discrepancy can cause compatibility issues for tools or scripts expecting consistent output.
Steps to Reproduce
- 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
- 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 WHERE 1=0" -s";" -W
- 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 WHERE 1=0" -s";" -W
Observed Behavior
go-sqlcmd Output:
(0 rows affected)
ODBC sqlcmd Output:
PointId;SessionId;Longitude;Latitude
-------;---------;---------;--------
(Righe interessate: 0)
Expected Behavior
When no rows are returned, go-sqlcmd should still include the column headers in the output, similar to the behavior of the ODBC sqlcmd.
Additional Information
This issue primarily affects the usability of go-sqlcmd in scenarios where scripts or applications rely on column headers to process query output, even when no rows are returned.
Request
Please investigate this behavior and align the output of go-sqlcmd with the ODBC-based sqlcmd when no results are returned.
Metadata
Metadata
Assignees
Labels
No labels