Skip to content

Implement string.Trim with parameters on SQL Server #22927

Description

@roji

We currently translate string.Trim only when no characters are specified (whitespace only), and implement it with LTRIM/RTRIM.

SQL Server 2017 introduced a more fully-featured TRIM function which can accept characters to trim. To maintain compatibility with older versions we can still use this only when non-whitespace characters are specified. Unfortunately no similar overloads exist for LTRIM/RTRIM (#22924).

Note that TRIM has a funky syntax (TRIM ( [ characters FROM ] string )), instead of just commas.

Activity

  1. roji commented on Oct 8, 2020

    @roji
    MemberAuthor

    Yeah, I have one too 🤣 Finally SQL Server will join the exclusive clique....

  2. added this to the Backlog milestone on Oct 9, 2020
  3. abdielcs commented on Jun 21, 2024

    @abdielcs
    Contributor

    I would like to know how you expect the new TRIM function with parameters to work. Could it be easily translated to something like LTRIM(RTRIM('MyString', 'CharsToTrim'), 'CharsToTrim'), or are you expecting to use the new TRIM ( [ characters FROM ] string ) syntax?

  4. roji commented on Jun 22, 2024

    @roji
    MemberAuthor

    We should definitely translate to the new SQL Server 2022 function, but the quirky syntax makes this a more difficult task. That goes beyond a beginner-level issue for sure.

  5. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions