You have a Microsoft SQL Servei 2025 database that contains a table named dbo.Customer-Messages, dbo.
Customer-Messages contains two columns named HessagelD (int) and MessageRaw (nvarchar(iux)).
MessageRaw can contain a phone number in multiple formats. and some rows do NOT contain a phone number. You need to write a single SELECT query that meets the following requirements:
* The query must return Message ID, RawNumber. DigitsOnly, and PhoneStatus.
* RawNumber must contain the first substring that matches a phone-number pattern, or NULL if no match exists.
* DigitsOnly must remove all non-digit characters from RawNumber. or return NULL.
* PhoneStatus must return Valid when a phone number exists in MessageRaw. otherwise return Missing.
How should you complete the Transact-SQL query? lo answer, drag the appropriate values To the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
NOTE: Each correct selection is worth one point.

Correct Answer:

Explanation:

The correct drag-and-drop mapping is based on the documented behavior of the new SQL regular expression functions.
For RawNumber , the requirement is to return the first substring in MessageRaw that matches the phone- number pattern, or NULL if nothing matches. That is exactly what REGEXP_SUBSTR does: it extracts the matched substring from the source text. Microsoft documents REGEXP_SUBSTR as the function that
"extracts parts of a string based on a regular expression pattern" and returns the matched occurrence.
For DigitsOnly , you first need the matched phone substring, then remove all non-digit characters from it. The correct combined expression is REGEXP_REPLACE( REGEXP_SUBSTR( so the matched substring is passed into REGEXP_REPLACE, which strips characters matching \D. Microsoft documents REGEXP_REPLACE as returning a modified source string with matching patterns replaced. Using it around REGEXP_SUBSTR satisfies the "digits only or NULL" requirement in one select expression.
For PhoneStatus , the requirement is simply to return Valid when a phone number exists and Missing otherwise. That is a Boolean test, so REGEXP_LIKE is the right function. Microsoft documents REGEXP_LIKE as returning a Boolean value indicating whether the input matches the regex pattern.