I'm in the process of building a partitioned table with a sliding-window partition. I have several years of historical static image data that will be moved to individual filegroups created to hold year's worth of data each. The Business requires that the last 60 days of images be updateable, everything older needs to be readonly which simplifies the backup process.
Since the PRIMARY filegroup is always READWRITE, I'm going to use the PRIMARY filegroup for the upper range of my partition to allow users to make necessary modifications to images in this 60 day window. On a nightly basis, I'm going to run a process that changes the upper range on the partition to the daterange = (getdate() - 60). The 61st day moves seamlessly from PRIMARY filegroup to my 2013FileGroup in milliseconds.
The process runs almost flawlessly, however, I'd like to change the FILEGROUP to READ-ONLY after moving the data to the archive partition. In my process, I can quickly switch this archive filegroup to READWRITE and run the Partition MERGE \ SPLIT to change my upper range and move records between partitions. However, I cannot change the FILEGROUP back to READ_ONLY without getting exclusive access to the entire database to save the change.
Is there any way to set a single FILEGROUP to read-only quickly without setting the entire DB to SINGLE-USER with ROLLBACK IMMEDIATE? I've tried the WITH ROLLBACK IMMEDIATE on the ALTER DB statement to modify the filegroup without any success. I need WRITE access for a matter of seconds before setting it back to read only. Any help would be greatly appreciated.
I'm dealing with a TB of data, a full restore could take 60+ hours to recover the entire db. However, doing partial backups on the READWRITE portion of the DB is done quickly and I can get the business back online quickly by recovering the PRIMARY filegroup and then restore readonly filegroups in the background. If I can't change these filegroups to read-only on the fly, I may have to maintain more backups for extended periods of time and may need to wait for maintenance windows to set filegroups to READONLY.