Skip to content

Commit 11042c3

Browse files
committed
Updating Few Scripts
Updating Few Scripts
1 parent 1da6256 commit 11042c3

21 files changed

+423
-47
lines changed
0 Bytes
Binary file not shown.

Backup-Restore/Backup-Restore.ssmssqlproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
66
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7-
<Created>2019-08-26T23:45:39.8361802-05:00</Created>
7+
<Created>2019-08-27T10:15:39.8361802+05:30</Created>
88
<Type>SQL</Type>
99
<Server>(local)</Server>
1010
<UserName />
@@ -16,7 +16,7 @@
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
1818
<ConnectionNode Name="LOCALHOST:CORPORATE\adwivedi">
19-
<Created>2019-10-08T07:32:23.4522102-05:00</Created>
19+
<Created>2019-10-08T18:02:23.4522102+05:30</Created>
2020
<Type>SQL</Type>
2121
<Server>LOCALHOST</Server>
2222
<UserName />
@@ -28,7 +28,7 @@
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
3030
<ConnectionNode Name="TUL1CIPCNPDB1:CORPORATE\adwivedi">
31-
<Created>2019-10-09T05:43:05.9153233-05:00</Created>
31+
<Created>2019-10-09T16:13:05.9153233+05:30</Created>
3232
<Type>SQL</Type>
3333
<Server>TUL1CIPCNPDB1</Server>
3434
<UserName />
@@ -40,7 +40,7 @@
4040
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
4141
</ConnectionNode>
4242
<ConnectionNode Name="TUL1CIPXDB20:CORPORATE\adwivedi">
43-
<Created>2019-10-09T11:59:39.1977294-05:00</Created>
43+
<Created>2019-10-09T22:29:39.1977294+05:30</Created>
4444
<Type>SQL</Type>
4545
<Server>TUL1CIPXDB20</Server>
4646
<UserName />
@@ -122,8 +122,8 @@
122122
<FullPath>Get-LatestBackups.sql</FullPath>
123123
</FileNode>
124124
<FileNode Name="Jobs-Enable-Disable-TSQL.sql">
125-
<AssociatedConnectionMoniker />
126-
<AssociatedConnSrvName />
125+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPCNPDB1:True</AssociatedConnectionMoniker>
126+
<AssociatedConnSrvName>TUL1CIPCNPDB1</AssociatedConnSrvName>
127127
<AssociatedConnUserName />
128128
<FullPath>Jobs-Enable-Disable-TSQL.sql</FullPath>
129129
</FileNode>
@@ -164,8 +164,8 @@
164164
<FullPath>ScriptOut - RESTORE With REPLACE - Single Db.sql</FullPath>
165165
</FileNode>
166166
<FileNode Name="v0.0 - Move Data and Log Files.sql">
167-
<AssociatedConnectionMoniker />
168-
<AssociatedConnSrvName />
167+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPCNPDB1:True</AssociatedConnectionMoniker>
168+
<AssociatedConnSrvName>TUL1CIPCNPDB1</AssociatedConnSrvName>
169169
<AssociatedConnUserName />
170170
<FullPath>v0.0 - Move Data and Log Files.sql</FullPath>
171171
</FileNode>

Backup-Restore/Jobs-Enable-Disable-TSQL.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ USE DBA
22
GO
33

44
/*
5-
StagingTurkey / StatingFiltered / MosaicFiltered and MosaicFiltered
6-
7-
CW Labeling Mosaic
8-
CW Labeling Staging
5+
SMU Change Tracking Version
6+
Replication jobs (only for Babel)
97
DataMart Filtering Mosaic
108
DataMart Filtering Staging Filtered
119
DataMart Filtering Staging Turkey
12-
13-
SP28 days 28 days on XDB13
10+
CW Labeling Mosaic
11+
CW Labeling Staging
12+
CW AMG Music Delta Pull
13+
CW Import AMG Video Data
1414
1515
*/
1616

@@ -19,7 +19,7 @@ EXEC msdb.dbo.sp_update_job @job_name = N'''+j.name+''', @enabled = 0 ;
1919
GO
2020
'
2121
from msdb..sysjobs_view j
22-
where j.name in ('CW Labeling Mosaic','CW Labeling Staging','DataMart Filtering Mosaic','DataMart Filtering Staging Filtered','DataMart Filtering Staging Turkey')
22+
where j.name in ('SMU Change Tracking Version' ,'DataMart Filtering Mosaic' ,'DataMart Filtering Staging Filtered' ,'DataMart Filtering Staging Turkey' ,'CW Labeling Mosaic' ,'CW Labeling Staging' ,'CW AMG Music Delta Pull' ,'CW Import AMG Video Data')
2323
and j.enabled = 1
2424

2525

Backup-Restore/v0.0 - Move Data and Log Files.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
SET NOCOUNT ON;
1010

1111
-- INPUT 01 -> Path for Data Files
12-
DECLARE @p_Old_Data_Path varchar(255) = 'K:\'; -- Leave NULL if no change required
13-
DECLARE @p_New_Data_Path varchar(255) = 'Q:\'; -- Leave NULL if no change required
12+
DECLARE @p_Old_Data_Path varchar(255) = 'P:\'; -- Leave NULL if no change required
13+
DECLARE @p_New_Data_Path varchar(255) = 'O:\'; -- Leave NULL if no change required
1414

1515
-- INPUT 02 -> Path for Log Files
16-
DECLARE @p_Old_Log_Path varchar(255) = 'L:'; -- Leave NULL if no change required
17-
DECLARE @p_New_Log_Path varchar(255) = 'Q:'; -- Leave NULL if no change required
16+
DECLARE @p_Old_Log_Path varchar(255) = 'P:'; -- Leave NULL if no change required
17+
DECLARE @p_New_Log_Path varchar(255) = 'O:'; -- Leave NULL if no change required
1818

1919
-- INPUT 03 -> Comma separated list of Databases
2020
IF OBJECT_ID('tempdb..#Dbs2Consider') IS NOT NULL
2121
DROP TABLE #Dbs2Consider;
2222
SELECT d.database_id, d.name, d.recovery_model_desc INTO #Dbs2Consider FROM sys.databases as d
2323
WHERE d.database_id > 4
24-
AND d.name IN ('MosaicFiltered')--,'StagingFiltered','StagingTurkey','MosaicFiltered','MosaicFiltered')
24+
AND d.name IN ('RCM_rovicore_20130710_NoMusic1a_en-US')--,'StagingFiltered','StagingTurkey','MosaicFiltered','MosaicFiltered')
2525

2626
-- Parameter Validations
2727
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)

BlitzQueries/BlitzQueries.ssmssqlproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
66
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7-
<Created>2019-08-22T06:49:33.2581521-05:00</Created>
7+
<Created>2019-08-22T17:19:33.2581521+05:30</Created>
88
<Type>SQL</Type>
99
<Server>(local)</Server>
1010
<UserName />
@@ -16,7 +16,7 @@
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
1818
<ConnectionNode Name="LOCALHOST:CORPORATE\adwivedi">
19-
<Created>2019-10-04T09:27:18.2935143-05:00</Created>
19+
<Created>2019-10-04T19:57:18.2935143+05:30</Created>
2020
<Type>SQL</Type>
2121
<Server>LOCALHOST</Server>
2222
<UserName />
@@ -28,7 +28,7 @@
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
3030
<ConnectionNode Name="tul1cipbksdb2:CORPORATE\adwivedi">
31-
<Created>2019-09-16T06:39:31.5964044-05:00</Created>
31+
<Created>2019-09-16T17:09:31.5964044+05:30</Created>
3232
<Type>SQL</Type>
3333
<Server>tul1cipbksdb2</Server>
3434
<UserName />
@@ -175,6 +175,12 @@
175175
<AssociatedConnUserName />
176176
<FullPath>SQL Server 2017 Diagnostic Information Queries.sql</FullPath>
177177
</FileNode>
178+
<FileNode Name="Very-Large-Databases-Optimization.sql">
179+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
180+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
181+
<AssociatedConnUserName />
182+
<FullPath>Very-Large-Databases-Optimization.sql</FullPath>
183+
</FileNode>
178184
<FileNode Name="Vw_WhoIsActive_Blocking.sql">
179185
<AssociatedConnectionMoniker />
180186
<AssociatedConnSrvName />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://blogs.msdn.microsoft.com/sqlserverstorageengine/2007/04/30/quick-list-of-vldb-maintenance-best-practices/
2+
3+
http://shaunjstuart.com/archive/2013/11/monitoring-for-endless-index-defragmenting/

LogShipping/LogShipping.ssmssqlproj

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
66
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7-
<Created>2019-09-06T02:04:33.3432862-05:00</Created>
7+
<Created>2019-09-06T12:34:33.3432862+05:30</Created>
88
<Type>SQL</Type>
99
<Server>(local)</Server>
1010
<UserName />
@@ -16,7 +16,7 @@
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
1818
<ConnectionNode Name="TUL1CIPCWRDB1:CORPORATE\adwivedi">
19-
<Created>2019-09-06T02:04:09.9908492-05:00</Created>
19+
<Created>2019-09-06T12:34:09.9908492+05:30</Created>
2020
<Type>SQL</Type>
2121
<Server>TUL1CIPCWRDB1</Server>
2222
<UserName />
@@ -28,7 +28,7 @@
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
3030
<ConnectionNode Name="TUL1CIPRDB1:CORPORATE\adwivedi">
31-
<Created>2019-09-06T02:03:03.3620427-05:00</Created>
31+
<Created>2019-09-06T12:33:03.3620427+05:30</Created>
3232
<Type>SQL</Type>
3333
<Server>TUL1CIPRDB1</Server>
3434
<UserName />
@@ -40,7 +40,7 @@
4040
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
4141
</ConnectionNode>
4242
<ConnectionNode Name="TUL1CIPXDB17:CORPORATE\adwivedi">
43-
<Created>2019-09-06T02:02:38.4613687-05:00</Created>
43+
<Created>2019-09-06T12:32:38.4613687+05:30</Created>
4444
<Type>SQL</Type>
4545
<Server>TUL1CIPXDB17</Server>
4646
<UserName />
@@ -52,7 +52,7 @@
5252
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
5353
</ConnectionNode>
5454
<ConnectionNode Name="TUL1CIPXDB20:CORPORATE\adwivedi">
55-
<Created>2019-09-06T01:40:47.3721186-05:00</Created>
55+
<Created>2019-09-06T12:10:47.3721186+05:30</Created>
5656
<Type>SQL</Type>
5757
<Server>TUL1CIPXDB20</Server>
5858
<UserName />
@@ -64,7 +64,7 @@
6464
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
6565
</ConnectionNode>
6666
<ConnectionNode Name="TUL1DBAPMTDB1\SQL2017:CORPORATE\adwivedi">
67-
<Created>2019-09-06T01:31:42.8901499-05:00</Created>
67+
<Created>2019-09-06T12:01:42.8901499+05:30</Created>
6868
<Type>SQL</Type>
6969
<Server>TUL1DBAPMTDB1\SQL2017</Server>
7070
<UserName />
@@ -127,6 +127,12 @@
127127
<AssociatedConnUserName />
128128
<FullPath>v1.0 - [usp_GetMail_4_SQLAlerts].sql</FullPath>
129129
</FileNode>
130+
<FileNode Name="v1.0 - Send-Mail-Upon-LogWalk-Success.sql">
131+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1DBAPMTDB1\SQL2017:True</AssociatedConnectionMoniker>
132+
<AssociatedConnSrvName>TUL1DBAPMTDB1\SQL2017</AssociatedConnSrvName>
133+
<AssociatedConnUserName />
134+
<FullPath>v1.0 - Send-Mail-Upon-LogWalk-Success.sql</FullPath>
135+
</FileNode>
130136
<FileNode Name="v1.1 - [usp_GetLogWalkJobHistoryAlert_Suppress].sql">
131137
<AssociatedConnectionMoniker />
132138
<AssociatedConnSrvName />
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
DECLARE @_mailSubject VARCHAR(255)
2+
,@_mailBody VARCHAR(4000)
3+
,@p_Mail_TO VARCHAR(1000)
4+
,@p_Mail_CC VARCHAR(1000)
5+
,@p_JobName VARCHAR(2000);
6+
7+
DECLARE @_IsInvokedByAutomation BIT = 0,
8+
@_RunDurationMinutes INT,
9+
@_IsSuccessFull BIT = 0;
10+
11+
SET @p_JobName = 'DBA Log Walk - Restore Staging as Staging';
12+
13+
SELECT TOP 1
14+
@_IsSuccessFull = CASE WHEN h.run_status = 1 THEN 1 ELSE 0 END,
15+
@_RunDurationMinutes = ((run_duration/10000*3600 + (run_duration/100)%100*60 + run_duration%100 + 31 ) / 60),
16+
@_IsInvokedByAutomation = (CASE WHEN h.message like 'The job succeeded. The Job was invoked by User CORPORATE\ProdSQL.%' THEN 1 ELSE 0 END)
17+
FROM msdb.dbo.sysjobs j
18+
INNER JOIN msdb.dbo.sysjobhistory h
19+
ON j.job_id = h.job_id
20+
WHERE j.name = @p_JobName
21+
AND step_id = 0
22+
ORDER BY j.name, h.instance_id desc;
23+
24+
--SET @p_Mail_TO = '[email protected]; [email protected]';
25+
SET @p_Mail_TO = '[email protected]';
26+
SET @_mailSubject = 'SQL Agent Job [DBA Log Walk - Restore Staging as Staging] is Successfull';
27+
SET @_mailBody = 'Dear DSG/DBA Team,
28+
29+
SQL Agent Job '+QUOTENAME(@p_JobName)+' has been successfully executed. No further action required.
30+
31+
32+
Thanks & Regards,
33+
SQL Alerts
34+
35+
-- Alert Coming from SQL Agent Job [DBA Log Walk - Restore Staging as Staging] - Step 04.
36+
'
37+
IF(@_IsSuccessFull = 0)
38+
BEGIN
39+
EXEC msdb..sp_send_dbmail @profile_name = @@servername,
40+
@recipients = @p_Mail_TO,
41+
--@copy_recipients = @p_Mail_CC,
42+
@subject = @_mailSubject,
43+
@body = @_mailBody;
44+
END

Misscellaneous Queries/Misscellaneous Queries.ssmssqlproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
66
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7-
<Created>2019-08-27T00:48:08.0273271-05:00</Created>
7+
<Created>2019-08-27T11:18:08.0273271+05:30</Created>
88
<Type>SQL</Type>
99
<Server>(local)</Server>
1010
<UserName />
@@ -16,7 +16,7 @@
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
1818
<ConnectionNode Name="LOCALHOST:CORPORATE\adwivedi">
19-
<Created>2019-10-04T09:05:12.0813596-05:00</Created>
19+
<Created>2019-10-04T19:35:12.0813596+05:30</Created>
2020
<Type>SQL</Type>
2121
<Server>LOCALHOST</Server>
2222
<UserName />
@@ -27,6 +27,18 @@
2727
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
30+
<ConnectionNode Name="TUL1CIPRDB1:CORPORATE\adwivedi">
31+
<Created>2019-10-14T12:19:07.252486+05:30</Created>
32+
<Type>SQL</Type>
33+
<Server>TUL1CIPRDB1</Server>
34+
<UserName />
35+
<Authentication>Windows Authentication</Authentication>
36+
<InitialDB>master</InitialDB>
37+
<LoginTimeout>30</LoginTimeout>
38+
<ExecutionTimeout>0</ExecutionTimeout>
39+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
40+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
41+
</ConnectionNode>
3042
</Items>
3143
</LogicalFolder>
3244
<LogicalFolder Name="Queries" Type="0" Sorted="true">
@@ -212,8 +224,8 @@
212224
<FullPath>System Memory Usage.sql</FullPath>
213225
</FileNode>
214226
<FileNode Name="TableSizeMetrics - RecordCount n PageCount.sql">
215-
<AssociatedConnectionMoniker />
216-
<AssociatedConnSrvName />
227+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPRDB1:True</AssociatedConnectionMoniker>
228+
<AssociatedConnSrvName>TUL1CIPRDB1</AssociatedConnSrvName>
217229
<AssociatedConnUserName />
218230
<FullPath>TableSizeMetrics - RecordCount n PageCount.sql</FullPath>
219231
</FileNode>

Misscellaneous Queries/Replace-Words-In-Body-Text-HTML.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ document.body.innerHTML = document.body.innerHTML.replace(/5.21/g, '7.21');
1313

1414
/* Edit PDF
1515
https://www.sejda.com/pdf-editor
16+
Convert-2-Secure-PDF
17+
http://www.pdfprotectfree.com/
1618
*/

0 commit comments

Comments
 (0)