I have a dataset with IDs and a phone number as a string. I need to build a flag to show if the string is in a valid format.
Here's a dummy dataset.
CREATE TABLE Test
(
ID int,
Cell varchar(11)
)
INSERT INTO Test (ID, Cell)
VALUES (1, '07123456789'),
(2, '441234567');
For now, a simple flag that indicates it started with a 0, for example, would be a good starting point for me. I've managed to figure out that Cell LIKE '^0%'
should make that work, but I can't figure out how to build it into a Boolean flag.
Thanks for any insights.
1条答案
按热度按时间kxkpmulp1#
You use a case expression (or inline-if) for this: