我有一个表格列如下:
DROP TABLE IF EXISTS #EXAMPLE;
CREATE TABLE #EXAMPLE(DistributionList VARCHAR(250));
INSERT INTO #EXAMPLE
values
('x@x.com; y@y.co.uk; me@me.com;'),
('me@me.com; a@a.com;'),
('me@me.com;'),
('NULL'),
('z@z.com; me@me.com;'),
('NULL'),
('c@c.co.uk; me@me.com; xx@x.com;'),
('NULL');
SELECT *
FROM #EXAMPLE;
如何剥离' me@me.com'来自列中的每个值?
答案 0 :(得分:1)
尝试 REPLACE
UPDATE #EXAMPLE
SET DistributionList = NULLIF(NULLIF(REPLACE(DistributionList, 'me@me.com;', ''), ''), ';')
FROM #EXAMPLE
WHERE DistributionList like '%me@me.com%'