added files from swmgmt03
This commit is contained in:
26
search object owner before deletion of user.sql
Normal file
26
search object owner before deletion of user.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
use UeberpruefungBAG2024
|
||||
|
||||
-- Replace 'username' with the actual username
|
||||
DECLARE @username NVARCHAR(128) = 'E-MEDIAT\uapvi';
|
||||
|
||||
-- Find schemas owned by the user
|
||||
SELECT schema_name(schema_id) AS SchemaName
|
||||
FROM sys.schemas
|
||||
WHERE principal_id = USER_ID(@username);
|
||||
|
||||
-- Find objects owned by the user
|
||||
SELECT
|
||||
o.name AS ObjectName,
|
||||
o.type_desc AS ObjectType,
|
||||
s.name AS SchemaName
|
||||
FROM
|
||||
sys.objects o
|
||||
JOIN
|
||||
sys.schemas s ON o.schema_id = s.schema_id
|
||||
WHERE
|
||||
o.principal_id = USER_ID(@username);
|
||||
GO
|
||||
|
||||
return
|
||||
|
||||
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [dbo];
|
||||
Reference in New Issue
Block a user