How do I terminate the old connection when a user of the same account login again? I want to set up a server while multiple users could login at the same time, as long as they are not the &quot;same user&quot;.
How could I set it up so when the user with the account username &quot;Bob&quot; login again, whether it's from the same computer or another, the old connection will be terminated?
Thanks for your help.
Much appreciated!
Edit:
&quot;Bob&quot; is a Database user account, the &quot;User ID&quot; in the &quot;Connection String&quot;, I'm sorry I don't really know what it is called.
You probably want to use a Logon Trigger to manage this. This specific part of the docs linked above mentions how you can limit the number of sessions for a specific Login:

You can use logon triggers to audit and control server sessions, such
as by tracking login activity, restricting logins to SQL Server, or
limiting the number of sessions for a specific login.

The first example in the docs is close to what you want, except it'll rollback the newer logins. If you want to kill the older logins you can use the login_time column of sys.dm_exec_sessions and kill the older sessions for that specific login_name.