Skip to content

Commit c7f2bbc

Browse files
author
Ajay Dwivedi
committed
Updating codes
Updating codes
1 parent 458409c commit c7f2bbc

10 files changed

+97
-15
lines changed
0 Bytes
Binary file not shown.

Backup-Restore/ScriptOut - RESTORE With REPLACE - Multiple Dbs.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SET NOCOUNT ON;
22

33
declare @p_dbName varchar(100);
44
declare @_backupFile varchar(2000);
5-
declare @_SourceServer varchar(255) = 'TUL1MDPDWMID01';
5+
declare @_SourceServer varchar(255) = 'YourSourceServer';
66
declare @sqlRestoreText varchar(max);
77
declare @tsqlFetchLastBackup varchar(max);
88
declare @counter int = 1;
@@ -14,9 +14,9 @@ IF OBJECT_ID('tempdb..#Dbs') IS NOT NULL
1414
SELECT ROW_NUMBER()OVER(ORDER BY dbName) as ID, dbName
1515
INTO #Dbs
1616
FROM (VALUES
17-
('Mosaic'),('MuzeUS'),('RCM_rovicore_20130710_NoMusic1a_en-US'),('Staging'),('Babel')
17+
('MuzeUS'),('AMG_avg'),('Twitter'),('MuzeVideo'),('DSG_EU'),('Prism'), ('FaceBook'), ('MuzeUK')
1818
) Databases(dbName);
19-
19+
-- $SimpleDbs = @('MuzeUS', 'AMG_avg', 'Twitter', 'MuzeVideo', 'DSG_EU', 'Prism', 'FaceBook', 'MuzeUK')
2020
select @total_counts = count(*) from #Dbs;
2121

2222
IF @_SourceServer IS NOT NULL
@@ -42,7 +42,7 @@ BEGIN
4242
FROM @SourceBackups AS v
4343
WHERE DbName = @p_dbName;
4444

45-
SET @_backupFile = CASE WHEN CHARINDEX(':',@_backupFile) > 0 THEN '\\TUL1MDPDWMID01\'+REPLACE(@_backupFile,':','$') ELSE @_backupFile END;
45+
SET @_backupFile = CASE WHEN CHARINDEX(':',@_backupFile) > 0 THEN '\\'+@_SourceServer+'\'+REPLACE(@_backupFile,':','$') ELSE @_backupFile END;
4646
END
4747

4848
set @sqlRestoreText = '

Baselining/Baselining.ssmssqlproj

+26-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@
3939
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
4040
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
4141
</ConnectionNode>
42+
<ConnectionNode Name="TUL1CIPBIAPP1:CORPORATE\adwivedi">
43+
<Created>2019-08-21T12:43:59.8900408+05:30</Created>
44+
<Type>SQL</Type>
45+
<Server>TUL1CIPBIAPP1</Server>
46+
<UserName />
47+
<Authentication>Windows Authentication</Authentication>
48+
<InitialDB />
49+
<LoginTimeout>30</LoginTimeout>
50+
<ExecutionTimeout>0</ExecutionTimeout>
51+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
52+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
53+
</ConnectionNode>
54+
<ConnectionNode Name="TUL1CIPBIAPP2:CORPORATE\adwivedi">
55+
<Created>2019-08-21T12:41:37.8867602+05:30</Created>
56+
<Type>SQL</Type>
57+
<Server>TUL1CIPBIAPP2</Server>
58+
<UserName />
59+
<Authentication>Windows Authentication</Authentication>
60+
<InitialDB />
61+
<LoginTimeout>30</LoginTimeout>
62+
<ExecutionTimeout>0</ExecutionTimeout>
63+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
64+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
65+
</ConnectionNode>
4266
<ConnectionNode Name="tul1cipcnpdb1:CORPORATE\adwivedi">
4367
<Created>2019-02-22T19:00:59.0595599+05:30</Created>
4468
<Type>SQL</Type>
@@ -200,8 +224,8 @@
200224
<FullPath>Job [DBA - FirstResponderKit_Collect_PerformanceData].sql</FullPath>
201225
</FileNode>
202226
<FileNode Name="Job [DBA - Log_With_sp_WhoIsActive].sql">
203-
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPRDB1:True</AssociatedConnectionMoniker>
204-
<AssociatedConnSrvName>TUL1CIPRDB1</AssociatedConnSrvName>
227+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPBIAPP1:True</AssociatedConnectionMoniker>
228+
<AssociatedConnSrvName>TUL1CIPBIAPP1</AssociatedConnSrvName>
205229
<AssociatedConnUserName />
206230
<FullPath>Job [DBA - Log_With_sp_WhoIsActive].sql</FullPath>
207231
</FileNode>

InstanceMigration/InstanceMigration.ssmssqlproj

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<Items>
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
6+
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7+
<Created>2019-08-21T13:31:34.7832695+05:30</Created>
8+
<Type>SQL</Type>
9+
<Server>(local)</Server>
10+
<UserName />
11+
<Authentication>Windows Authentication</Authentication>
12+
<InitialDB />
13+
<LoginTimeout>30</LoginTimeout>
14+
<ExecutionTimeout>0</ExecutionTimeout>
15+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
16+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
17+
</ConnectionNode>
618
<ConnectionNode Name="Ann1vesPDb01:CORPORATE\adwivedi">
719
<Created>2019-03-12T12:04:52.0528151+05:30</Created>
820
<Type>SQL</Type>
@@ -55,6 +67,12 @@
5567
<AssociatedConnUserName />
5668
<FullPath>Move-TempDb.sql</FullPath>
5769
</FileNode>
70+
<FileNode Name="SQLQuery1.sql">
71+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
72+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
73+
<AssociatedConnUserName />
74+
<FullPath>SQLQuery1.sql</FullPath>
75+
</FileNode>
5876
</Items>
5977
</LogicalFolder>
6078
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">

InstanceMigration/SQLQuery1.sql

Whitespace-only changes.

LogShipping/LogShipping.ssmssqlproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@
194194
<FullPath>v1.4 - [usp_GetLogWalkJobHistoryAlert_Suppress].sql</FullPath>
195195
</FileNode>
196196
<FileNode Name="v1.5 - [usp_GetLogWalkJobHistoryAlert_Suppress].sql">
197-
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPCWRDB1:True</AssociatedConnectionMoniker>
198-
<AssociatedConnSrvName>TUL1CIPCWRDB1</AssociatedConnSrvName>
197+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPXDB18:True</AssociatedConnectionMoniker>
198+
<AssociatedConnSrvName>TUL1CIPXDB18</AssociatedConnSrvName>
199199
<AssociatedConnUserName />
200200
<FullPath>v1.5 - [usp_GetLogWalkJobHistoryAlert_Suppress].sql</FullPath>
201201
</FileNode>

LogShipping/v1.5 - [usp_GetLogWalkJobHistoryAlert_Suppress].sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ ORDER BY r.collection_time, LEVEL ASC;
520520
IF @p_Verbose = 1
521521
PRINT 'Checking if last mail was sent more than '+cast(@p_TimeIntervalForMailNotification as varchar(10))+' minutes (@p_TimeIntervalForMailNotification) ago.';
522522

523-
SET @LastMailNotificationTimeInMinutes = COALESCE((select datediff(MINUTE,max(si.sent_date),getdate()) from msdb.dbo.sysmail_sentitems as si where si.subject like '%'+@p_JobName+'%'),0 );
523+
SET @LastMailNotificationTimeInMinutes = COALESCE((select datediff(MINUTE,max(si.sent_date),getdate()) from msdb.dbo.sysmail_sentitems as si where si.subject like 'SQL Agent Job !['+@p_JobName+'%' ESCAPE '!'),0 );
524524

525525
-- Send notification mail if threshold time is crossed
526526
IF(@p_TimeIntervalForMailNotification <= @LastMailNotificationTimeInMinutes )

Space Issues/Invoke-DbaDbShrink.sql

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Invoke-DbaDbShrink -SqlInstance 'TSQLPRD01' `
2+
-Database AMGMusicAuthority,EntryAggregation,RoviTunes,VendorLinkProcess,VestaMusicProcessing,Workspace `
3+
-FileType Log `
4+
-StepSize 2048MB

Space Issues/Space Issues.ssmssqlproj

+18
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
4040
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
4141
</ConnectionNode>
42+
<ConnectionNode Name="TUL1CIPRDB1:CORPORATE\adwivedi">
43+
<Created>2019-08-21T10:26:38.0570294+05:30</Created>
44+
<Type>SQL</Type>
45+
<Server>TUL1CIPRDB1</Server>
46+
<UserName />
47+
<Authentication>Windows Authentication</Authentication>
48+
<InitialDB>master</InitialDB>
49+
<LoginTimeout>30</LoginTimeout>
50+
<ExecutionTimeout>0</ExecutionTimeout>
51+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
52+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
53+
</ConnectionNode>
4254
<ConnectionNode Name="tul1cipxdb98:CORPORATE\adwivedi">
4355
<Created>2019-05-10T15:57:39.3409079+05:30</Created>
4456
<Type>SQL</Type>
@@ -73,6 +85,12 @@
7385
<AssociatedConnUserName />
7486
<FullPath>Get-VolumeInfo.sql</FullPath>
7587
</FileNode>
88+
<FileNode Name="Invoke-DbaDbShrink.sql">
89+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPRDB1:True</AssociatedConnectionMoniker>
90+
<AssociatedConnSrvName>TUL1CIPRDB1</AssociatedConnSrvName>
91+
<AssociatedConnUserName />
92+
<FullPath>Invoke-DbaDbShrink.sql</FullPath>
93+
</FileNode>
7694
<FileNode Name="Ola Log Backup.sql">
7795
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPEDB2:True</AssociatedConnectionMoniker>
7896
<AssociatedConnSrvName>TUL1CIPEDB2</AssociatedConnSrvName>

TempDb-Issues/TempDb-Issues.ssmssqlproj

+24-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<Items>
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
6+
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7+
<Created>2019-08-20T17:13:40.8978696+05:30</Created>
8+
<Type>SQL</Type>
9+
<Server>(local)</Server>
10+
<UserName />
11+
<Authentication>Windows Authentication</Authentication>
12+
<InitialDB />
13+
<LoginTimeout>30</LoginTimeout>
14+
<ExecutionTimeout>0</ExecutionTimeout>
15+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
16+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
17+
</ConnectionNode>
618
<ConnectionNode Name="tul1cipcnpdb1:CORPORATE\adwivedi">
719
<Created>2019-04-21T19:26:00.4704679+05:30</Created>
820
<Type>SQL</Type>
@@ -19,23 +31,29 @@
1931
</LogicalFolder>
2032
<LogicalFolder Name="Queries" Type="0" Sorted="true">
2133
<Items>
22-
<FileNode Name="Find-Longest-Running-Query-TempLog.sql">
34+
<FileNode Name="Alert-TempDb-Files-Space-Usage.sql">
2335
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:tul1cipcnpdb1:True</AssociatedConnectionMoniker>
2436
<AssociatedConnSrvName>tul1cipcnpdb1</AssociatedConnSrvName>
2537
<AssociatedConnUserName />
26-
<FullPath>Find-Longest-Running-Query-TempLog.sql</FullPath>
38+
<FullPath>Alert-TempDb-Files-Space-Usage.sql</FullPath>
2739
</FileNode>
28-
<FileNode Name="Find-TempDb-Space-Issues.sql">
40+
<FileNode Name="Find-Db-Files-Space-Usage.sql">
41+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
42+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
43+
<AssociatedConnUserName />
44+
<FullPath>Find-Db-Files-Space-Usage.sql</FullPath>
45+
</FileNode>
46+
<FileNode Name="Find-Longest-Running-Query-TempLog.sql">
2947
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:tul1cipcnpdb1:True</AssociatedConnectionMoniker>
3048
<AssociatedConnSrvName>tul1cipcnpdb1</AssociatedConnSrvName>
3149
<AssociatedConnUserName />
32-
<FullPath>Find-TempDb-Space-Issues.sql</FullPath>
50+
<FullPath>Find-Longest-Running-Query-TempLog.sql</FullPath>
3351
</FileNode>
34-
<FileNode Name="TempDb-Files-Space-Usage.sql">
52+
<FileNode Name="Raw-Queries-TempDb-Space-Issues.sql">
3553
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:tul1cipcnpdb1:True</AssociatedConnectionMoniker>
3654
<AssociatedConnSrvName>tul1cipcnpdb1</AssociatedConnSrvName>
3755
<AssociatedConnUserName />
38-
<FullPath>TempDb-Files-Space-Usage.sql</FullPath>
56+
<FullPath>Raw-Queries-TempDb-Space-Issues.sql</FullPath>
3957
</FileNode>
4058
<FileNode Name="v0.0 - [usp_getDatabaseFileSpaceUsageNotification].sql">
4159
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:tul1cipcnpdb1:True</AssociatedConnectionMoniker>

0 commit comments

Comments
 (0)