Skip to content

SA0223 : The MODIFY FILEGROUP READONLY and READWRITE syntax is deprecated

Using deprecated keywords for database filegroup modifications can lead to compatibility issues and potential failures in future versions of SQL Server.

In SQL Server, managing database filegroups is a common task that includes setting filegroups to either READONLY or READWRITE . However, the ALTER DATABASE MODIFY FILEGROUP command with these keywords is deprecated and will be removed in future versions of SQL Server.

For example:

-- Deprecated usage of altering database filegroup
ALTER DATABASE MyDatabase MODIFY FILEGROUP MyFileGroup READONLY;

Using these keywords is problematic because:

  • Future-proofing your application becomes difficult, as continued use of these commands can lead to breaking changes when upgrading SQL Server versions.

  • It may indicate legacy or outdated code practices that could potentially lead to compatibility issues.

Modify your T-SQL code to avoid using deprecated keywords like READONLY and READWRITE when altering database filegroups.

Follow these steps to address the issue:

1.Open your T-SQL script or query in SQL Server Management Studio (SSMS).

2.Locate any instance of the ALTER DATABASE MODIFY FILEGROUP command that uses the READONLY or READWRITE keywords.

3.Replace the deprecated syntax with the updated command: MODIFY FILEGROUP READ_ONLY or READ_WRITE as appropriate.

4.Execute the modified query to apply the changes to your database.

For example:

-- Corrected usage of altering database filegroup
ALTER DATABASE MyDatabase MODIFY FILEGROUP MyFileGroup READ_ONLY;

The rule has a Batch scope and is applied only on the SQL script.

Rule has no parameters.

The rule does not need Analysis Context or SQL Connection.

20 minutes per issue.

Deprecated Features, Bugs

Deprecated Database Engine Features in SQL Server 2017

ALTER DATABASE TestDb1 MODIFY FILEGROUP Fg1 READONLY;
ALTER DATABASE TestDb1 MODIFY FILEGROUP Fg2 READWRITE
  Message Line Column
1 SA0223 : The MODIFY FILEGROUP READONLY and READWRITE syntax is deprecated. 1 45
2 SA0223 : The MODIFY FILEGROUP READONLY and READWRITE syntax is deprecated. 3 45

Analysis Rules