USE master;
GO
ALTER DATABASE AdventureWorks2022
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AdventureWorks2022
SET READ_ONLY;
GO
ALTER DATABASE AdventureWorks2022
SET MULTI_USER;
GO