Skip to content

remove sqlserver 7 and 2000 support#4015

Open
SimonCropp wants to merge 10 commits into
dotnet:mainfrom
SimonCropp:remove-sqlserver-7-and-2000-support
Open

remove sqlserver 7 and 2000 support#4015
SimonCropp wants to merge 10 commits into
dotnet:mainfrom
SimonCropp:remove-sqlserver-7-and-2000-support

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes support for SQL Server 7.0 and SQL Server 2000 from the driver.

SQL Server 2000's mainstream support ended on April 8, 2008, and extended support ended on April 9, 2013, so it has been fully unsupported for over 12 years. SQL Server 7.0 is older still. The driver already refused to connect to these versions (TDS version negotiation has required SQL Server 2005 or later for a long time — anything below 0x72 throws SQL.InvalidTDSVersion()), so the protocol-level code paths for 7.0/2000 were effectively dead. This PR removes that dead code along with the now-orphaned SQL Server 2000 type-system compatibility option.

Public API / behavior changes

⚠️ The following are observable behavior changes worth calling out for release notes.

  1. Type System Version=SQL Server 2000 connection-string value removed.
    The TypeSystem.SQLServer2000 enum value and the "SQL Server 2000" parsing branch are removed from SqlConnectionOptions. A connection string that specifies Type System Version=SQL Server 2000 now throws ArgumentException (ADP.InvalidConnectionOptionValue) when the connection is opened, instead of being accepted.

    • This option was decoupled from the actual server version (it could be set against a modern server to request 2000-compatible type surfacing), so it is the one change here that could affect a real application. The remaining values — Latest, SQL Server 2005, SQL Server 2008, SQL Server 2012 — are unchanged.
    • Note: the connection-string documentation already only listed 2012/2008/2005/Latest as valid values, so this brings the implementation in line with the documented surface.
  2. SqlDataReader no longer applies SQL Server 2000 type-system mapping.
    The TypeSystem.SQLServer2000-specific branches and the GetVersionedMetaType legacy down-level type coercion are removed (~215 lines). Only affects applications that previously set Type System Version=SQL Server 2000.

There is no change to which servers the driver will connect to — 7.0/2000 servers were already rejected during login version negotiation before this PR.

Code changes

Product (src/Microsoft.Data.SqlClient/src)

  • SqlConnectionOptions.cs — remove TypeSystem.SQLServer2000 enum value and "SQL Server 2000" type-system parsing (behavior change SqlSpatial #1).
  • SqlDataReader.cs — remove 2000 type-system code paths and GetVersionedMetaType (behavior change Fixed link to release notes #2).
  • TdsEnums.cs — remove 7.0/2000 TDS version constants/comments (the SQL2005_*/SQL2008_*/etc. constants are unchanged).
  • TdsParser.cs — remove dead 7.0/2000 handling and stale comments; version-negotiation switch is unchanged (still rejects anything below 2005).
  • SqlConnectionInternal.cs, SqlInternalTransaction.cs, SqlParameter.cs — comment-only cleanup of obsolete 7.0/2000 references; no behavior change.

Tests (src/Microsoft.Data.SqlClient/tests)

  • tools/TDS/TDS/TDSVersion.cs — the simulated TDS server retains SqlServer7_0/SqlServer2000 and the major-7/8 mappings in GetTDSVersion, and IsSupported keeps its <= SQL Server 2012 bound, so the server can still emit a genuine legacy 7.0/2000 LOGINACK. This is deliberately preserved so the unit test can exercise the driver's real client-side rejection. (Clarifying comments only; behavior matches main.)
  • UnitTests/SimulatedServerTests/ConnectionTests.csConnectionTestDeniedVersion is renamed to ConnectionRefusesUnsupportedServerTdsVersion (7.0, 2000 RTM, 2000 SP1) and continues to assert InvalidOperationException. The simulated server emits a legacy LOGINACK and the driver rejects the pre-2005 TDS version in TryProcessLoginAck via SQL.InvalidTDSVersion(), so this is genuine client-side legacy-version-rejection coverage (addresses review thread r3468675054).

Checklist

  • Tests added/updated
  • Public API behavior changes documented (see above; suggest a breaking-change entry in release notes for the removed Type System Version=SQL Server 2000 value)
  • CI Project pipeline: 17519
  • CI Package pipeline: 17519
  • Kerberos pipeline: 20260624.5
  • Managed Instance pipeline: 158028

@SimonCropp SimonCropp requested a review from a team as a code owner March 6, 2026 13:54
Copilot AI review requested due to automatic review settings March 6, 2026 13:54
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Mar 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to remove legacy SQL Server 7.0 / 2000 compatibility paths (and related “Type System Version” handling) from SqlClient and its test TDS tooling.

Changes:

  • Removed SQL Server 7.0 / 2000 mappings from the test TDS version helper and tightened supported TDS range to 2005–2012.
  • Removed TypeSystemVersion=SQL Server 2000 parsing support and deleted SQL Server 2000-specific branches in SqlDataReader.
  • Cleaned up several legacy-version comments across core TDS/transaction code paths.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs Removes SQL7/2000 version constants and mapping; tightens supported TDS range.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs Updates legacy-version comments in TDS parsing logic.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs Removes 2000-era versioning comment lines; updates datatype “version introduced” comment.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs Simplifies legacy server notes around parameter size/type elevation.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs Removes SQL7/2000-specific commentary from zombie handling explanation.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs Removes SQL Server 2000-specific type-system behavior and helper method.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs Drops SQL Server 2000 from TypeSystemVersion recognized values.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs Updates transaction enlistment comments to remove SQL7/2000 references.
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53

  • GetTDSVersion now throws NotSupportedException for server build majors other than 9/10/11. The simulated TDS server is still used in unit tests with ServerVersion majors 7 and 8 (e.g., tests/UnitTests/SimulatedServerTests/ConnectionTests.cs), so this will throw during server login handling and likely break those tests (and the ability to simulate legacy servers). Consider keeping mappings for 7.0/2000 in the test server, or update/remove the tests and any callers that still pass 7/8 versions.
            else
            {
                // Not supported TDS version
                throw new NotSupportedException("Specified build version is not supported");
            }

Comment thread src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs Outdated
@paulmedynski paulmedynski added the Code Health 💊 Issues/PRs that are targeted to source code quality improvements. label Mar 9, 2026
@paulmedynski paulmedynski modified the milestones: 7.0.1, 7.1.0-preview1 Mar 9, 2026
@benrr101 benrr101 moved this from To triage to In review in SqlClient Board Mar 17, 2026
…arser.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 26, 2026 00:45
…arameter.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53

  • GetTDSVersion no longer handles server build versions with major 7 or 8. The simulated TDS server (GenericTdsServer.OnLogin7Request) calls TDSVersion.GetTDSVersion(Arguments.ServerVersion) during login, so starting a test server with ServerVersion = new Version(7, …) or new Version(8, …) will now result in an unhandled NotSupportedException instead of the server returning a clean “unsupported TDS version” response. This is likely to break existing simulated-server unit tests that validate the client rejects SQL Server 7.0/2000. Consider either keeping the 7.0/2000 mapping here for negative-testing purposes, or catching NotSupportedException at the call site and treating it as an unsupported version via CheckTDSVersion.
        public static Version GetTDSVersion(Version buildVersion)
        {
            // Check build version Major part
            if (buildVersion.Major == 11)
            {
                return SqlServer2012;
            }
            else if (buildVersion.Major == 10)
            {
                return SqlServer2008;
            }
            else if (buildVersion.Major == 9)
            {
                return SqlServer2005;
            }
            else
            {
                // Not supported TDS version
                throw new NotSupportedException("Specified build version is not supported");
            }

@paulmedynski paulmedynski self-assigned this Apr 7, 2026

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with one Copilot comment to address.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 7, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53

  • GetTDSVersion now throws NotSupportedException for server build versions with major 7/8. GenericTdsServer.OnLogin7Request calls this without a try/catch, so starting the simulated server with SQL 7.0/2000 versions will crash the server-side handler rather than returning a clean protocol error to the client. This will also break existing simulated-server unit tests that still cover denied SQL 7.0/2000 versions (e.g., SimulatedServerTests/ConnectionTests.ConnectionTestDeniedVersion). Consider either removing/updating those tests as part of this PR, or changing GetTDSVersion (or its caller) to handle unsupported build versions gracefully (e.g., return an error token / deny connection) instead of throwing.
            else
            {
                // Not supported TDS version
                throw new NotSupportedException("Specified build version is not supported");
            }

@SimonCropp

Copy link
Copy Markdown
Contributor Author

in src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlParameter.cs

we have

                    // Elevation from (n)(var)char (4001+) to (n)text for SQL Server 2000 compatibility (legacy behavior)
                    maxSizeInBytes = (sizeInCharacters > actualSizeInBytes) ? sizeInCharacters : actualSizeInBytes;

should that change?

@mdaigle

mdaigle commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

in src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlParameter.cs

we have

                    // Elevation from (n)(var)char (4001+) to (n)text for SQL Server 2000 compatibility (legacy behavior)
                    maxSizeInBytes = (sizeInCharacters > actualSizeInBytes) ? sizeInCharacters : actualSizeInBytes;

should that change?

I would want to see it in a standalone PR. It would require more scrutiny to understand if it's safe to change.

mdaigle
mdaigle previously approved these changes Apr 16, 2026
@mdaigle

mdaigle commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@cheenamalhotra cheenamalhotra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to make sure there are no environmental regressions - recommend running internal Test pipelines too, Kerberos and Managed Instance targeted tests.

Will approve when we have conformation on no regressions.

@paulmedynski paulmedynski removed the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Jun 8, 2026
@paulmedynski

Copy link
Copy Markdown
Contributor

I'm taking over this PR - @SimonCropp please don't make any updates without coordinating with me first. Thanks!

@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@SimonCropp

Copy link
Copy Markdown
Contributor Author

@paulmedynski thanks

@paulmedynski paulmedynski enabled auto-merge (squash) June 17, 2026 13:04
@cheenamalhotra

Copy link
Copy Markdown
Member

@paulmedynski assigned to you since you're already monitoring it.

Copilot AI review requested due to automatic review settings June 23, 2026 16:25
@paulmedynski paulmedynski removed the Author attention needed PRs that require author to respond or make updates to PR. label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs:53

  • GetTDSVersion no longer maps SQL Server major versions 7 (SQL 7.0) and 8 (SQL 2000) and now throws NotSupportedException. The simulated server uses TDSVersion.GetTDSVersion(Arguments.ServerVersion) (e.g., TDS.Servers/GenericTdsServer.cs:287), and there are existing unit tests that still start the simulated server with ServerVersion 7.x/8.x (e.g., tests/UnitTests/SimulatedServerTests/ConnectionTests.cs InlineData for 7.0 and 2000). As-is, those tests/server scenarios will fail during login handling before the client can validate/reject the legacy server version. Either remove/update those tests/scenarios or keep the legacy build-version mapping here (even if the main driver drops support).
        public static Version GetTDSVersion(Version buildVersion)
        {
            // Check build version Major part
            if (buildVersion.Major == 11)
            {
                return SqlServer2012;
            }
            else if (buildVersion.Major == 10)
            {
                return SqlServer2008;
            }
            else if (buildVersion.Major == 9)
            {
                return SqlServer2005;
            }
            else
            {
                // Not supported TDS version
                throw new NotSupportedException("Specified build version is not supported");
            }

Comment thread src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSVersion.cs
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionOptions.cs Outdated
@paulmedynski paulmedynski added the Public API 🆕 Issues/PRs that introduce new APIs to the driver. label Jun 24, 2026
- ConnectionTests: ConnectionTestDeniedVersion now expects SqlException instead of
  InvalidOperationException for SQL Server 7.0/2000, since the simulated TDS server
  no longer emits a login for those versions and the client fails to connect.
- TDSVersion.IsSupported: enforce a 2005 lower bound so pre-2005/invalid TDS
  versions cannot be negotiated as a downgraded version.
- SqlConnectionOptions: remove the redundant TypeSystem.Latest enum member (it
  duplicated SQLServer2008); map the 'Latest' connection-string value to
  SQLServer2008 at parse time with rationale, and document that 'Latest' is a
  badly named sentinel value.
- SqlParameter: replace the stale 'SQL Server 2000' comment with the unit/encoding
  rationale.
Track the Azure-project SSPI failure under the new task instead of #40107.
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run sqlclient-pr

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

- Guard graph-table (AS NODE/AS EDGE) UnprivilegedLogin test on SQL 2017+,
  since graph tables are unsupported on SQL Server 2016.
- Correct CopyAllFromReader pre-2017 IduCount/Transactions expectations from
  0 to 1; the least-privilege bulk copy change (dotnet#4306) added one IDU/transaction
  but only updated the >=2017 branch, leaving the pre-2017 branch stale.
Copilot AI review requested due to automatic review settings June 24, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionOptions.cs:490

  • Type System Version=SQL Server 2000 was removed from parsing (now falls into the InvalidConnectionOptionValue case), which is an observable behavior change. There doesn’t appear to be any automated test coverage that opening a connection with this value now throws ArgumentException (and that other values like Latest/SQL Server 2005/2008/2012 remain accepted). Adding a regression test would help prevent accidental reintroduction or a future change to where/when validation occurs.
            if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.Latest, StringComparison.OrdinalIgnoreCase))
            {
                // "Latest" (and the default when no version is specified) intentionally maps to
                // SQL Server 2008 rather than the newest defined type system. Advancing it would
                // alter type mappings (e.g. the Microsoft.SqlServer.Types assembly version and how
                // down-level types are surfaced) for existing applications that rely on the default,
                // which would be a breaking change. Newer type systems must be requested explicitly.
                _typeSystemVersion = TypeSystem.SQLServer2008;
            }
            else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2005, StringComparison.OrdinalIgnoreCase))
            {
                _typeSystemVersion = TypeSystem.SQLServer2005;
            }
            else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2008, StringComparison.OrdinalIgnoreCase))
            {
                _typeSystemVersion = TypeSystem.SQLServer2008;
            }
            else if (typeSystemVersionString.Equals(TYPESYSTEMVERSION.SQL_Server_2012, StringComparison.OrdinalIgnoreCase))
            {
                _typeSystemVersion = TypeSystem.SQLServer2012;
                _typeSystemAssemblyVersion = s_constTypeSystemAsmVersion11;
            }
            else
            {
                throw ADP.InvalidConnectionOptionValue(DbConnectionStringKeywords.TypeSystemVersion);
            }

…sions (PR dotnet#4015)

The simulated TDS server had lost the ability to emit a legacy 7.0/2000
LOGINACK, so ConnectionTestDeniedVersion only proved a generic connection
failure (the test server threw NotSupportedException before sending a login),
not that the driver rejects unsupported server versions.

- TDSVersion: restore SqlServer7_0/SqlServer2000 constants and the major 7/8
  branches in GetTDSVersion, and revert IsSupported to <= SqlServer2012 so the
  simulated server emits a genuine legacy LOGINACK.
- ConnectionTests: rename the test to ConnectionRefusesUnsupportedServerTdsVersion
  and assert InvalidOperationException - the driver's real rejection via
  SQL.InvalidTDSVersion() in TryProcessLoginAck.

Addresses review thread r3468675054.
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run sqlclient-pr, CI-SqlClient, CI-SqlClient-Package

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Health 💊 Issues/PRs that are targeted to source code quality improvements. Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

6 participants