I want to replace all numbers in SQL with a single * value. I've researched the issue, but been unable to replicate what I've found. I also feel like I'm over complicating this process. Here is the break down of what I'm doing currently:
Create temp table Replacing numbers with *.
This is the part I need help with. I need to replace multiple characters with a single *.
Final step is querying my data and GROUPING my data.
Query:
CREATE TABLE #CMS_ERROR_LOG
(
ERROR_LOG_BODY NVARCHAR(MAX),
);
INSErT INTO #CMS_ERROR_LOG
select REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE ([ERROR_LOG_BODY], '0', '*'),
'1', '*'),
'2', '*'),
'3', '*'),
'4', '*'),
'5', '*'),
'6', '*'),
'7', '*'),
'8', '*'),
'9', '*')
FROM CMS_ERROR_LOG
WHERE ERROR_LOG_MESSAGE = 'API Request Capture'
SELECT
SUBSTRING([ERROR_LOG_BODY],1,CHARINDEX(',', [ERROR_LOG_BODY])-2) AS 'Request'
FROM #CMS_ERROR_LOG
GROUP BY SUBSTRING([ERROR_LOG_BODY],1,CHARINDEX(',', [ERROR_LOG_BODY])-2)
I read something about using # in the replace statement to only replace with single char but unable to get it to work.
Current Result: [POST] URL: https://localhost:*/api/authentication/authenticat
Desired result: [POST] URL: https://localhost:*/api/authentication/authenticat