Skip to content

Commit d9f9dbe

Browse files
author
Ajay Dwivedi
committed
Added few more scripts
Added few more scripts
1 parent b9e5089 commit d9f9dbe

8 files changed

+64
-2
lines changed
-10 KB
Binary file not shown.

InstanceMigration/Disable-Jobs.sql

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Declare @JobId NVarchar(600)
2+
Declare Cur Cursor For
3+
Select job_id --,j.name
4+
from msdb..sysjobs_view as j
5+
Where name not Like 'DBA%'
6+
and name not in ('Nightly Maintenance','CommandLog Cleanup','Archive_Maintenance','sp_purge_jobhistory','Long Running Jobs Check','Backup Logs','Capture_blocking','sp_delete_backuphistory','syspolicy_purge_history')
7+
and j.enabled = 1
8+
9+
Open Cur
10+
Fetch Cur Into @JobId
11+
While @@FETCH_STATUS=0
12+
Begin
13+
EXEC msdb.dbo.sp_update_job @job_id=@JobId, @enabled=0
14+
Fetch Cur Into @JobId
15+
End
16+
Close Cur
17+
Deallocate Cur

InstanceMigration/InstanceMigration.ssmssqlproj

+12
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
<AssociatedConnUserName />
6262
<FullPath>Copy-SSIS-Packages.sql</FullPath>
6363
</FileNode>
64+
<FileNode Name="Disable-Jobs.sql">
65+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
66+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
67+
<AssociatedConnUserName />
68+
<FullPath>Disable-Jobs.sql</FullPath>
69+
</FileNode>
6470
<FileNode Name="Estimate-Backup-Size-Full.sql">
6571
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
6672
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
@@ -113,6 +119,12 @@
113119
<AssociatedConnUserName />
114120
<FullPath>PowerShell.ps1</FullPath>
115121
</FileNode>
122+
<FileNode Name="SQL SERVER MIGRATION USING POWERSHELL.docx">
123+
<AssociatedConnectionMoniker />
124+
<AssociatedConnSrvName />
125+
<AssociatedConnUserName />
126+
<FullPath>SQL SERVER MIGRATION USING POWERSHELL.docx</FullPath>
127+
</FileNode>
116128
</Items>
117129
</LogicalFolder>
118130
</Items>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
https://stackoverflow.com/questions/14952833/get-wmiobject-win32-process-computername-gets-error-access-denied-code-0x8
2+
-- https://stackoverflow.com/a/14953535/4449743
3+
-- https://stackoverflow.com/a/11338395/4449743
4+
Launch "wmimgmt.msc"
5+
Right-click on "WMI Control (Local)" then select Properties
6+
Go to the "Security" tab and select "Security" then "Advanced" then "Add"
7+
Select the user name(s) or group(s) you want to grant access to the WMI and click ok
8+
Grant the required permissions, I recommend starting off by granting all permissions to ensure that access is given, then remove permissions later as necessary.
9+
Ensure the "Apply to" option is set to "This namespace and subnamespaces"
10+
Save and exit all prompts
11+
Add the user(s) or group(s) to the Local "Distributed COM Users" group. Note: The "Authenticated Users" and "Everyone" groups cannot be added here, so you can alternatively use the "Domain Users" group.
12+
13+
netsh advfirewall firewall set rule group="Windows Management Instrumentation (WMI)" new enable=yes
14+
15+
-- =======================================================================================
16+
#Install-Module CredentialManager -Force;
17+
#Get-Command -Module CredentialManager
18+
$computerName = 'msi';
19+
20+
Get-Credential -UserName "$computerName\Ajay" -Message "Password please" | New-StoredCredential -Target $computerName -Persist LocalMachine
21+
$creds = Get-StoredCredential -Target $computerName;
22+
23+
Get-VolumeInfo -ComputerName $computerName
24+
Get-DbaDiskSpace -ComputerName $computerName -Credential $creds

PowerShell Commands/PowerShell Commands.ssmssqlproj

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
<AssociatedConnUserName />
8686
<FullPath>Different-Files-Between-Paths.sql</FullPath>
8787
</FileNode>
88+
<FileNode Name="Enable-Powershell-for-Local-LAN-System.sql">
89+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
90+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
91+
<AssociatedConnUserName />
92+
<FullPath>Enable-Powershell-for-Local-LAN-System.sql</FullPath>
93+
</FileNode>
8894
<FileNode Name="EnhancedHtml.sql">
8995
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1DBAPMTDB1\SQL2017:True</AssociatedConnectionMoniker>
9096
<AssociatedConnSrvName>TUL1DBAPMTDB1\SQL2017</AssociatedConnSrvName>

Replication-Transactional/DBA - Replication - Reduce REPL_SCHEMA_ACCESS Wait.sql

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ exec sp_WhoIsActive @filter = '221'
2222
2323
select getdate() as currentTime, * from DistributorServer.DBA.dbo.JobRunningStateChangeLog l
2424
where l.collectionTime >= dateadd(minute,-90,getdate())
25-
and Source = 'usp_RemoveReplSchemaAccessContention' order by collectionTime desc;
25+
--and Source = 'usp_RemoveReplSchemaAccessContention'
26+
order by collectionTime desc;
2627
2728
--exec DistributorServer.DBA.dbo.usp_ChangeJobRunningState @jobs = 'TUL1CIPCNPDB1-StagingFiltered-1'
2829
-- ,@state = 'Start', @verbose = 1

Replication-Transactional/__General Queries.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,6 @@ on a.id = dh.agent_id
108108
where a.publication = 'Mosaic_2014'
109109
ORDER BY time DESC
110110

111-
--select * from dbo.MSdistribution_agents as a
111+
--select * from dbo.MSdistribution_agents as a
112+
113+
https://www.mssqltips.com/sqlservertip/3598/troubleshooting-transactional-replication-latency-issues-in-sql-server/

0 commit comments

Comments
 (0)