This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
d.PERCENT_COMPLETE AS [%Complete], | |
d.TOTAL_ELAPSED_TIME/60000 AS ElapsedTimeMin, | |
d.ESTIMATED_COMPLETION_TIME/60000 AS TimeRemainingMin, | |
d.TOTAL_ELAPSED_TIME*0.00000024 AS ElapsedTimeHours, | |
d.ESTIMATED_COMPLETION_TIME*0.00000024 AS TimeRemainingHours, | |
s.text AS Command | |
FROM sys.dm_exec_requests d | |
CROSS APPLY sys.dm_exec_sql_text(d.sql_handle)as s | |
WHERE d.COMMAND LIKE 'backup DATABASE%' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--generate grant statements | |
declare @sql varchar(8000) | |
declare loop1 cursor | |
for | |
SELECT prin.[name] [User],object_name(major_id) objName, sec.state_desc + ' ' + sec.permission_name [Permission] | |
--into #tmp | |
FROM [sys].[database_permissions] sec | |
JOIN [sys].[database_principals] prin | |
ON sec.[grantee_principal_id] = prin.[principal_id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
SPID | |
,Status | |
,loginame | |
,HostName | |
,blocked | |
,open_tran | |
,waittype | |
,cmd | |
,Last_Batch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @name varchar(max) | |
DECLARE @sql nvarchar(max) | |
DECLARE name CURSOR FOR | |
select dp.name from sys.database_principals dp | |
join sys.syslogins l on l.name = dp.name | |
OPEN name | |
FETCH NEXT FROM name INTO @name |
NewerOlder