The following query runs for about 15 minutes on a 77,000,000 row temporary table. This is too long. I expect there is a more efficient to do this without the replicate() and cast() functions. Any help is appreciated.
update #sometable set Period = cast(year(StartTime) as char(4)) + '-' + replicate('0', 2 - len(rtrim(cast(month(StartTime) as varchar(2))))) + cast(month(StartTime) as varchar(2))