пятница, 15 декабря 2023 г.

MSDistribution cleanup

 EXEC dbo.sp_MSdistribution_cleanup @min_distretention = 0, @max_distretention = 24


select count(*) from distribution..msrepl_commands

select count(*) from distribution..msrepl_transactions


go

DECLARE @rowcountCom int = 5000000

DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 



DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 



DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 


go

DELETE TOP(@rowcountCom) MSrepl_commands WITH (PAGLOCK) 

FROM MSrepl_commands 

WITH (INDEX(ucMSrepl_commands)) 


понедельник, 17 апреля 2023 г.

Read acces to SQL JOBS

 use msdb

CREATE USER "Group_or_USer" FOR LOGIN "Group_or_USer"";
ALTER ROLE SQLAgentReaderRole add member "Group_or_USer""

Read access to Stored Procedures

use [Database]


SELECT N'GRANT VIEW DEFINITION ON '

    + QUOTENAME(SPECIFIC_SCHEMA)

    + N'.'

    + QUOTENAME(SPECIFIC_NAME)

    + N' to "Group_or_User";'

FROM INFORMATION_SCHEMA.ROUTINES

WHERE ROUTINE_TYPE = 'PROCEDURE';