Forked from dhmacher/sql-messages-without-whitespaces.sql
Created
July 26, 2022 21:43
-
-
Save hero827/5758e8b02a7e30a7d417e4439a2942b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- TRANSLATE() and STRING_SPLIT() work with SQL Server 2016+, STRING_AGG() with 2017+. | |
| -- language_id=1033 is English (simplified) | |
| SELECT STRING_AGG(REPLACE(TRANSLATE(s.[value] COLLATE database_default, '():.,-/='';', '**********'), '*', ''), ' ') | |
| FROM sys.messages AS msg | |
| CROSS APPLY STRING_SPLIT(msg.[text], ' ') AS s | |
| WHERE msg.language_id=1033 | |
| --AND s.[value] COLLATE database_default NOT IN ('the', 'is', 'to', 'not', 'a', 'for', 'in', 'be', 'of', 'or', 'cannot', 'and') | |
| AND s.[value] COLLATE database_default NOT LIKE '%[%@=]%' | |
| GROUP BY msg.message_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment