MSSQL

SQL to check Bitbucket user permission

TonyW
Bitbucket permission can be assigned at project level or repository level for a group and user. The SQL (MSSQL Server) below can be used to check all projects & repositories permission for a given user, include the access assigned to an individual user or a group. with repo_access as ( select distinct p.id as "Project ID", p.name as "Project Name", r.name as "Repo Name", cu.id as "User ID (Individual)", cu.user_name as "Username (Individual)", Concat(cu.

Restore MSSQL Database

TonyW
Kill active sessions Firstly, it would be better to stop all the applications/services which are connecting to the Database which needs a restore. Then, kill the active sessions as this will block the restore process if there are any active sessions. use master; declare @kill varchar(max) = ''; select @kill = @kill + 'kill ' + convert(varchar(10),S.session_id) + ';' from sys.dm_exec_sessions S join master..sysprocesses P on P.spid = S.session_id where P.