Question: I have **multiple** databases to change mode from `Single-User` to `Multi-User`.
I can use this to change one database.

```
USE master;
GO
ALTER DATABASE CDN_Ceramika
SET MULTI_USER;
GO

```

Is it possible to change mode for few bases or any query, when mode will be change for Multi-User just when a mode is Single-User?

Answer: 
If you are new to database management I'd advise *against* using `sys.sp_MSforeachdb`. Despite being undocumented it's a *very* popular function among DBAs that know and quadruple-check what they're doing. [This article](https://www.mssqltips.com/sqlservertip/2201/making-a-more-reliable-and-flexible-spmsforeachdb/) explains some of its pitfalls.

It's generally safer to generate the command strings you want to execute with SQL, inspect them, fix any problems and execute the resulting script. Probably inside a transaction if appropriate.

As the article shows `sp_MSforeachdb` itself queries the `sys.databases` table. You can do the same, eg with :

```
select 'ALTER DATABASE [' + name + '] SET MULTI_USER;'
from sys.databases
where name not in ('master','tempdb','model','msdb')

```

To generate `ALTER DATABASE` for all the databases you want, whose names match the `WHERE` clause. You could also write :

```
select 'ALTER DATABASE [' + name + '] SET MULTI_USER;'
from sys.databases
where name not in ('master','tempdb','model','msdb')
and [user_access_desc] != 'MULTI_USER'

```

to exclude databases that are already in multi-user mode
Right click on the database you wish to change, then click on Properties.

Click on Options and scroll down to the bottom, then set it as can be seen below:

[![enter image description here](https://i.stack.imgur.com/FfXeu.png)](https://i.stack.imgur.com/FfXeu.png)

Click OK and it will be set.