T-SQL Decommenter Part II

  • Comments posted to this topic are about the item T-SQL Decommenter Part II

  • Or using powershell and regex

    ([regex]"(?im)--.*?$").replace(([regex]"(?s)\/\*.*?\*\/").replace($sql, ""), "")

  • will 58232 - Thursday, November 15, 2018 12:03 AM

    Or using powershell and regex

    ([regex]"(?im)--.*?$").replace(([regex]"(?s)\/\*.*?\*\/").replace($sql, ""), "")

    That will work much of the time, but here are a couple of examples that will get mangled:
    ([regex]"(?im)--.*?$").replace(([regex]"(?s)\/\*.*?\*\/").replace("SELECT '-- in string'", ""), "")
    ([regex]"(?im)--.*?$").replace(([regex]"(?s)\/\*.*?\*\/").replace("/*SELECT /*'Nested'*/'Commented'`r`n*/`r`nSELECT 'Uncommented'", ""), "")

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply