I have a column that has a month name in it as well as other text after the name of a specific month. What i want to do is extract the Months from that column and create a new column named Month.
|Ops/SLA Month |
|APRIL SLA Reporting|
|APRIL OPS Reporting|
|Months |OPS/SLA |
|April |SLA Reporting|
|April |OPS Reporting|
You can try a query like below
create table tbl ([Ops/SLA Month] varchar(max));
insert into tbl values
('APRIL SLA Reporting')
,('APRIL OPS Reporting');
select
month = m.month,
[OPS/SLA]= substring(t.[Ops/SLA Month],LEN(m.month)+1,8000)
from tbl t cross join
(values
('January'),('February'),('March'),
('April'),('may'),('june'),
('july'),('August'),('September'),
('October'),('November'),('December'))m(month)
where t.[Ops/SLA Month] like m.month +'%'