tag:blogger.com,1999:blog-21397620051347951522024-03-13T22:08:51.895-07:00DBAtasksAn occasional series about SQL Server tasks for DBAsJackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.comBlogger70125tag:blogger.com,1999:blog-2139762005134795152.post-80375810981733679412022-07-19T07:43:00.000-07:002022-07-19T07:43:12.377-07:00Cycling The Error Logs<br /><br />Error Logs? Surely you don't have errors? :)<br /><br />Well, SQL Server records pretty much everything, so it can get a bit unmanageable. If there are a million errors in your log file, it takes a long time to open that file and tell you what is happening. So I have a two step agent job that runs each week - DBAdmin Cycle Error Logs<div><br /></div><div>Step 1 : execute dbo.sp_cycle_errorlog<br />Step 2: execute dbo.sp_cycle_agent_errorlog</div><div><br /></div><div>SQL Server by default retains 6 logs, and although you can configure it to retain more, I can't imagine a reason for wanting to look at an error from more than six weeks ago. </div><div><br /></div><div>However, on some of my servers, my job fails - Step 1 works, Step 2 fails with an access denied message:</div><div><br /></div><div><i>Executed as user: Domain\Server_Agent. SQLServerAgent Error: Access is denied. [SQLSTATE 42000] (Error 22022). The step failed.</i></div><div><i><br /></i></div><div>I noticed that the error log is actually being cycled. </div><div>The error message relates to the system attempting to write to the log to say what it has done</div><div>In my case, the system is logging SQL Server messages in file: </div><div>'E:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG'.</div><div><br /></div><div>So, as so often with weird stuff in SQL Server, it's a permissions issue</div><div><br /></div><div>I set list permission for the SQL agent account all the way to:<br /> E:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL<br /> then set Modify on the Log folder</div><div><br /></div><div>I ran the job again, it failed again, argh!</div><div><br /></div><div>And here’s the crucial bit that I didn’t do at first:</div><div> Restart SQL Server Agent Service</div><div><br /></div><div>I ran the job again, and it worked</div>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-14243497910312193442020-05-15T07:39:00.002-07:002020-05-15T07:39:59.607-07:00How to Kill a DatabaseIt's not very likely that you will need to get rid of databases on the production side, but certainly development boxes can be full of junk - test databases, experiments that didn't work out, projects that got cancelled... So you just drop the junk DB, right? <br />
<br />
Wrong...<br />
<br />
Get the business owner to confirm in writing before you do this stuff, and be prepared to retrieve it in case they change their mind. This is pretty much the opposite of business as usual, so beware.<br />
<br />
1)<span class="Apple-tab-span" style="white-space: pre;"> </span>You can make a database read-only. It is no longer in use, but the users might want to look at historical data sometimes. The users can still see their data, but they can't change anything. But if an application tries to record something like date_last_accessed, it won't work. Consider running optimization processes, such as full UPDATE STATISTICS before changing the status to read only .<br />
<br />
<br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">--update statistics</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">use</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: teal;">Vanilla</span></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">Go</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">exec</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: maroon;">sp_updatestats</span></span></div>
<br />
<br />
<br />
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- to make a database read only</span><br />
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla </span><span style="color: blue;">set</span> <span style="color: blue;">read_only</span> <span style="color: blue;">with</span> <span style="color: blue;">rollback</span> <span style="color: blue;">immediate</span><span style="color: grey;">;</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">go</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- and back to normal</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla </span><span style="color: blue;">set</span> <span style="color: blue;">read_write</span><span style="color: grey;">;</span><o:p></o:p></span></div>
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">go<o:p></o:p></span><br />
<br />
The rollback immediate thing will cope with anyone who is in the middle of working on the database (the one they told you is no longer in use). Of course, it may be a process rather than a person. You may need to make the database single-user<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- if other people are using it, take
control</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla</span> <span style="color: blue;">set</span> <span style="color: blue;">single_user</span> <span style="color: blue;">with</span> <span style="color: blue;">rollback</span> <span style="color: blue;">immediate;</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">--and give it back</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla</span> <span style="color: blue;">set</span> <span style="color: blue;">multi_user</span><span style="color: grey;">;</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<br /></div>
<br />
<div class="MsoNormal">
<br /></div>
<br />
<br />
2)<span class="Apple-tab-span" style="white-space: pre;"> </span>You can take a database offline. This is a step beyond read only; the users can't see it but you can. If it turns out that they need it after all, it's usually the work of a moment to bring it back online. If not <a href="https://stackoverflow.com/questions/60380975/unable-to-bring-online-any-database-on-a-server" target="_blank">this may help</a>.<br />
<br />
Taking a database offline is a wise precaution to take before deleting it. Tell the helpdesk to let you know if anyone screams. Wait for a month or two, maybe three, depending.. Put a note in Outlook to remind you in three months, otherwise it will stay offline forever. If you are using SQL Server 2005, you may need to tinker with your maintenance plans - the option to ignore offline dbs only came in with 2008. <br />
<br />
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- Take the Database Offline</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla</span> <span style="color: blue;">set</span> <span style="color: blue;">offline</span> <span style="color: blue;">with</span> <span style="color: blue;">rollback</span> <span style="color: blue;">immediate</span><span style="color: grey;">;</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">go</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- Bring the Database back Online</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">alter</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">database</span> <span style="color: teal;">Vanilla</span> <span style="color: blue;">set</span> <span style="color: blue;">online</span><span style="color: grey;">;</span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">go<o:p></o:p></span></div>
<br />
<br />
<br />
<br />
3)<span class="Apple-tab-span" style="white-space: pre;"> </span>You can detach a database. It's still there, but you can't see it or get it back without a bit of effort. If the file naming isn't routine, it might be very fiddly indeed. <br />
<br />
Out of sight, out of mind - once you have detached a database "temporarily" you can't see it unless you go on the box and browse to the folder(s) where the files live. So before you detach the Vanilla database, run this:<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">execute</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: maroon;">sp_helpdb</span><span style="color: blue;"> </span><span style="color: teal;">Vanilla<o:p></o:p></span></span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="color: teal;"><br /></span></span></div>
This will show you where the files live; copy the results into an Outlook task and mark it for attention a couple of weeks hence. Something like this:<br />
<br />
<br />
<table border="0" cellpadding="0" cellspacing="0" style="width: 714px;"><colgroup><col style="mso-width-alt: 2852; mso-width-source: userset; width: 59pt;" width="78"></col>
<col style="width: 48pt;" width="64"></col>
<col style="mso-width-alt: 9216; mso-width-source: userset; width: 189pt;" width="252"></col>
<col span="5" style="width: 48pt;" width="64"></col>
</colgroup><tbody>
<tr height="20" style="height: 15.0pt;">
<td height="20" style="height: 15.0pt; width: 59pt;" width="78">name<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64">fileid<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 189pt;" width="252">filename<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64">filegroup<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64">size<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64"><span style="mso-spacerun: yes;"> </span>usage<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64">maxsize<span style="mso-spacerun: yes;"> </span></td>
<td style="width: 48pt;" width="64">growth</td>
</tr>
<tr height="20" style="height: 15.0pt;">
<td height="20" style="height: 15.0pt;">Vanilla</td>
<td align="right">1</td>
<td>E:\MSSQL.1\MSSQL\DATA\Vanilla.MDF</td>
<td>PRIMARY</td>
<td>7808 KB</td>
<td>Unlimited</td>
<td align="right" class="xl63">10%</td>
<td>data only</td>
</tr>
<tr height="20" style="height: 15.0pt;">
<td height="20" style="height: 15.0pt;">Vanilla_Log</td>
<td align="right">2</td>
<td>F:\MSSQL\Logs\Vanilla_Log.LDF</td>
<td>NULL</td>
<td>1024 KB</td>
<td>Unlimited</td>
<td align="right" class="xl63">10%</td>
<td>log only</td>
</tr>
</tbody></table>
<br />
There's a fair chance that you or your predecessor forgot to take this precaution some time in the last 10 years. This might mean that the server (especially, as I say, if it's a dev box) is cluttered with long forgotten detached databases. <br />
<br />
The script below looks for databases which are not attached to the current instance. Unfortunately if you have other instances on the box, it will detect those databases too. (If you can tell me how to fix that, I'll be very grateful). But apart from that, it's very good at finding potentially forgotten files which are taking up space that you can use. <br />
<br />
It uses xp_cmdshell, so assuming you probably have this disabled by default, enable it before and disable it afterwards for security reasons. (Be careful though - if it isn't disabled by default, you might end up disabling something important. ) Then it creates a temporary table, populates it with a list of .mdf files, and compares the mdf files it finds with a list of those that are attached.<br />
<br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">---- enable these jobs</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">---- show advanced options</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_configure</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'show
advanced options'</span><span style="color: grey;">,</span> 1<span style="color: grey;">;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">RECONFIGURE</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">---- enable xp_cmdshell</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_configure</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'xp_cmdshell'</span><span style="color: grey;">,</span> 1<span style="color: grey;">;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">RECONFIGURE</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- based on
http://www.sqlservercentral.com/Forums/Topic6166-5-1.aspx</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- create temporary table</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">create</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">table</span> <span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: teal;">full_filename</span> <span style="color: blue;">varchar</span><span style="color: grey;">(</span>200<span style="color: grey;">)</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">-</span><span style="color: teal; font-family: "consolas"; font-size: 9.5pt;">populate</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: teal;">the</span> <span style="color: teal;">temp</span> <span style="color: blue;">table</span> <span style="color: blue;">with</span> <span style="color: grey;">any</span> <span style="color: teal;">MDF</span> <span style="color: teal;">files</span> <span style="color: teal;">found</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">insert</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: blue;">exec</span> <span style="color: maroon;">xp_cmdshell</span><span style="color: blue;"> </span><span style="color: red;">'dir c:\*.mdf /s/b'</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">insert</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: blue;">exec</span> <span style="color: maroon;">xp_cmdshell</span><span style="color: blue;"> </span><span style="color: red;">'dir d:\*.mdf /s/b'</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">insert</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: blue;">exec</span> <span style="color: maroon;">xp_cmdshell</span><span style="color: blue;"> </span><span style="color: red;">'dir e:\*.mdf /s/b'</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">select</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: green;">-- exclude the subdirectory name</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: magenta;">upper</span><span style="color: grey;">(</span><span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: magenta;">substring</span><span style="color: grey;">(</span><span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: teal;">full_filename</span> <span style="color: grey;">),</span> 1<span style="color: grey;">,</span><span style="color: magenta;">charindex</span><span style="color: grey;">(</span><span style="color: red;">'\'</span><span style="color: grey;">,</span> <span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: teal;">full_filename</span> <span style="color: grey;">)</span> <span style="color: grey;">)-</span>1<span style="color: grey;">)</span> <span style="color: grey;">))</span> <span style="color: blue;">As</span> <span style="color: teal;">MDF_FileName</span><span style="color: grey;">,</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: teal;">full_filename</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">from</span><span style="font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">where</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: green;">--exclude rows which contain system messages or nulls</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: teal;">full_filename</span> <span style="color: grey;">like</span> <span style="color: red;">'%\%'</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">and</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: green;">--exclude system databases</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: magenta;">upper</span><span style="color: grey;">(</span><span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: magenta;">substring</span><span style="color: grey;">(</span><span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: teal;">full_filename</span> <span style="color: grey;">),</span> 1<span style="color: grey;">,</span><span style="color: magenta;">charindex</span><span style="color: grey;">(</span><span style="color: red;">'\'</span><span style="color: grey;">,</span> <span style="color: magenta;">reverse</span><span style="color: grey;">(</span><span style="color: teal;">full_filename</span> <span style="color: grey;">)</span> <span style="color: grey;">)-</span>1<span style="color: grey;">)</span> <span style="color: grey;">))</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">not</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: grey;">in</span> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="color: red; font-family: "consolas"; font-size: 9.5pt;">'DISTMDL.MDF'</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'MASTER.MDF'</span><span style="color: grey;">,</span> <span style="color: red;">'MODEL.MDF'</span><span style="color: grey;">,</span> <span style="color: red;">'MSDBDATA.MDF'</span> <span style="color: grey;">,</span> <span style="color: red;">'MSSQLSYSTEMRESOURCE.MDF'</span><span style="color: grey;">,</span> <span style="color: red;">'TEMPDB.MDF'</span> <span style="color: grey;">)</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">and</span><span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: green;">-- MDF filename excluding the subdirectory name</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="color: teal;">full_filename</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">not</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: grey;">in</span> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">select</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: magenta;">Upper</span><span style="color: grey;">(</span><span style="color: blue;">FILEname</span><span style="color: grey;">)</span> <span style="color: blue;">from</span> <span style="color: green;">sys</span><span style="color: grey;">.</span><span style="color: green;">SYSdatabases</span><span style="color: grey;">)</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- -- SQL Server 2000</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">--<span style="mso-tab-count: 1;"> </span>not
in (select Upper(FILEname) from sysdatabases)<span style="mso-spacerun: yes;">
</span></span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">order</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">by</span> <span style="color: teal;">MDF_FileName</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- Housekeeping</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">drop</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">table</span> <span style="color: teal;">#temp_mdf_files</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- disable these jobs</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- show advanced options</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_configure</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'show
advanced options'</span><span style="color: grey;">,</span> 1<span style="color: grey;">;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">RECONFIGURE</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- disable xp_cmdshell</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_configure</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'xp_cmdshell'</span><span style="color: grey;">,</span> 0<span style="color: grey;">;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">RECONFIGURE</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;">-- hide advanced options</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_configure</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: red;">'show
advanced options'</span><span style="color: grey;">,</span> 0<span style="color: grey;">;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">RECONFIGURE</span><span style="color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span><span style="font-family: "consolas"; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]--><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
4) You can drop a database<br />
<br />
You're sure? Really sure? <br />
<br />
<br />
Not if it's offline, you can't. You need to bring it back online before you do that. It might disappear from SSMS, but the physical files are still lurking in there. In fact I suspect that the reason I am housekeeping a list of detached databases is that people have taken them offline <!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Someone dropped the database but because it was offline it
never got deleted – it just stayed on as a detached DB</div>
<br />
<br />
<br />
<br />
And take a backup before you drop it. Zip up the backup and save it in your Final Backups folder. <br />
<br /></div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-73394666284867081692020-05-15T07:31:00.001-07:002020-05-15T07:31:25.337-07:00Monitoring Mirroring<span style="font-family: inherit;"><span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">S</span><span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">ince Mirroring is now deprecated in favour of Always On, I think it is a minority sport these days</span></span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">But it works perfectly well, especially if you haven't got Always On. In a perfect world, we would all upgrade to the latest version as soon as it comes out, and take advantage of all the whizzy new features. But we don't, of course</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Anyway, monitoring mirroring. A bit of a tongue twister, that. </span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Assuming you have set up mirroring already, right click on the database you want to monitor, select Tasks, and choose Launch Database Mirroring Monitor</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Click on the Warnings tab. Do this for each of the mirrored databases</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Initially, it doesn't monitor anything. Tucked away in the bottom right of the screen is a button marked Set Thresholds. Click on it and tick all the boxes</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7Gpgqxmnu26sPW9bw9KZ01pQvKBT3EgcaYyx-BklTMDaKU_We-sccQj43no7OgONzX1WmruHPaq6AAWbD_iwPdfswjTE0e9wwwuAvxFjnc_ifrtehqB9OYBZwuVKXxOKXZBKqcVdmYtNZ/s1600/Mirroring+Monitor.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="648" data-original-width="1152" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7Gpgqxmnu26sPW9bw9KZ01pQvKBT3EgcaYyx-BklTMDaKU_We-sccQj43no7OgONzX1WmruHPaq6AAWbD_iwPdfswjTE0e9wwwuAvxFjnc_ifrtehqB9OYBZwuVKXxOKXZBKqcVdmYtNZ/s640/Mirroring+Monitor.png" width="640" /></a></div>
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Microsoft sets these defaults - </span><br />
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Unsent log exceeds 1KB</span><br />
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Unrestored log exceeds 1KB</span><br />
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Oldest unsent transaction exceeds 1 minute</span><br />
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Mirror commit overhead exceeds 1millisecond</span><br />
<span style="font-family: inherit;"><br style="background-attachment: scroll; background-color: transparent; background-image: none; background-repeat: repeat; background-size: auto; color: #222222; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; padding: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /></span>
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">I would recommend starting with these and seeing how it goes. You will almost certainly end up upping those defaults, but it probably isn't my place to tell you what to do</span><br />
<span style="font-family: inherit;"><br id="if_insertedNode_1547481548709" style="background-attachment: scroll; background-color: transparent; background-image: none; background-repeat: repeat; background-size: auto; color: #222222; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; padding: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" /></span>
<span style="background-color: white; color: #222222; cursor: text; display: inline; float: none; font-family: inherit; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 24px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Remember to go to the SQL Agent jobs - find Database Mirroring Monitor Job - and set it to Notify you if it finds a problem. </span><br />
<span style="font-family: inherit;"><b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br /></span>
<div style="background-color: transparent; color: black; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<span style="font-family: inherit;">Be sure to set up the alerts and the Agent Job at both servers, so that it continues to alert you in the event of a failover. </span></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-24226723520148214842020-05-12T08:19:00.002-07:002020-05-12T08:19:52.598-07:00NotificationsI have a script to check that I have got my SQL Server Agent jobs right. <br />
<br />
<b>#1 Owner not SA</b><br /><br />The default owner of the agent job you set up is you. Well, that's fine, until you leave the company, they disable your account, and everything falls over. So I tend to make sure that all the jobs have the owner SA. In a prefect world you might think about setting up an account just to run SQL Agent jobs. I'll make an exception for SharePoint jobs, which I prefer not to touch with a BargePole<br />
<br />
<br />
<br />
-- 1 - Owner not SA<br />
--**************************************************************<br />
select <br />
'1 - Owner not SA' as Problem,<br />
suser_sname(sj.owner_sid ) as Owner,<br />
replace(replace(sj.name,char(10),' - '),char(13),' ') as Job_Name,<br />
replace(replace(sj.[Description],char(10),' - '),char(13),' ') as Job_Description<br />
from<br />
msdb.[dbo].[sysjobs] sj<br />
where<br />
suser_sname(sj.owner_sid ) not in <br />
(<br />
'SA',<br />
'SharePoint'<br />
)<br />
order by <br />
[enabled] desc,<br />
sj.name<br />
<br />
<br />
<br />
<b>#2 Jobs with no description</b><br />
<br />
Whoever set the job up didn't bother to put in a description. Well, you don't actually NEED a description. But when the job fails, you will be left sitting there wondering what the heck the job is supposed to be doing and who set it up and when<br />
<br />
So just a brief sentence, maybe a paragraph, plus the name of the guy to contact and the date. Even if it's you - chances are that you won't remember it in a year's time - that description will help a lot<br />
<br />
<br />
-- 2 - No description available.<br />
--**************************************************************<br />
select <br />
'2 - No description available' as Problem,<br />
suser_sname(sj.owner_sid ) as Owner,<br />
replace(replace(sj.name,char(10),' - '),char(13),' ') as Job_Name,<br />
replace(replace(sj.[Description],char(10),' - '),char(13),' ') as Job_Description<br />
from<br />
msdb.[dbo].[sysjobs] sj<br />
where<br />
sj.[Description] = 'No description available.'<br />
or <br />
sj.[Description] = ''<br />
order by <br />
[enabled] desc,<br />
sj.name<br />
<br />
<br />
<br />
<b>#3 Not Logging completion</b><br />
<b><br /></b>
You don't NEED to put stuff in the logs<br />
But if you don't, what's the point of having a log?<br />
<br />
<br />
-- 3 - Jobs which are not set to update event log on completion<br />
--**************************************************************<br />
select <br />
'3 - update event log on completion' as Problem,<br />
suser_sname(sj.owner_sid ) as Owner,<br />
replace(replace(sj.name,char(10),' - '),char(13),' ') as Job_Name,<br />
replace(replace(sj.[Description],char(10),' - '),char(13),' ') as Job_Description,<br />
sj.[enabled],<br />
sj.notify_email_operator_id,<br />
sj.notify_level_eventlog,<br />
sj.notify_level_email<br />
from<br />
msdb.[dbo].[sysjobs] sj<br />
where<br />
sj.notify_level_eventlog not in <br />
(<br />
2 -- failure<br />
,3 -- completion<br />
)<br />
order by <br />
[enabled] desc,<br />
sj.name<br />
<br />
/*<br />
-- update event log on completion (i.e. success AND failure)<br />
update msdb.[dbo].[sysjobs] <br />
set notify_level_eventlog = 3 -- on completion<br />
where notify_level_eventlog in <br />
(<br />
0 --not set<br />
,2 -- on failure <br />
)<br />
*/<br />
<br />
<br />
<br />
<b>#4 Who you gonna call?</b><br />
<br />
You really don't want the job to fail and nobody knows about it, do you?<br />Oh, you check every day? Every single job on every single server? Even during your vacations? Well good for you. <br />
<br />
I don't. I get SQL Server to send an email to the DBAdmin team if anything falls over<br />
The exception is the <a href="https://dbatasks.blogspot.com/2018/03/heartbeat.html" target="_blank">Heartbeat Monitor</a><br />
<br />
<br />
-- 4 - Jobs which are not set to email on failure<br />
-- DBAdmin Heartbeat Monitor should email on success (1)<br />
--**************************************************************<br />
select <br />
'4 - not set to email on failure',<br />
suser_sname(sj.owner_sid ) as Owner,<br />
replace(replace(sj.name,char(10),' - '),char(13),' ') as Job_Name,<br />
replace(replace(sj.[Description],char(10),' - '),char(13),' ') as Job_Description,<br />
sj.[enabled],<br />
sj.notify_email_operator_id,<br />
sj.notify_level_eventlog,<br />
sj.notify_level_email<br />
from<br />
msdb.[dbo].[sysjobs] sj<br />
where<br />
sj.notify_level_email not in<br />
(<br />
2 -- failure<br />
,3 -- completion<br />
)<br />
order by <br />
[enabled] desc,<br />
sj.name<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-20763474718838392712020-05-11T14:11:00.002-07:002020-05-11T14:11:51.180-07:00SSIS Meaningless Error MessagesMy SSIS package failed.<br />
<br />
It's a simple job that copies data older than 15 days from Database A on premises to Database B in Azure. It then deletes the old data from Database A. So a simple archive job. There's not much there to fail - and it runs every day - just not today. <br />
<br />
Well, let's have a look at the error messages in the Progress tab:<br />
<br />
<i>[ADO NET Destination [16]] Error: An exception has occurred during data insertion, the message returned from the provider is: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</i><br />
<i><br /></i>
<i>[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "ADO NET Destination" (16) failed with error code 0xC020844B while processing input "ADO NET Destination Input" (19). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.</i><br />
<i><br /></i>
<i>[OLE DB Source [1]] Error: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.</i><br />
<i><br /></i>
<i>[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "OLE DB Source" (1) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.</i><br />
<i></i><br />
There now, isn't that informative?<br />
Well, now that I have worked out what went wrong, it is - here are the important words in all that guff:<br />
<br />
<div style="text-align: center;">
<b>An exception has occurred during data insertion</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
It is trying to add data to the destination and fails, reporting a timeout. </div>
<br />
The hexadecimal stuff doesn't really help me terribly much. It looks really specific - but when you google it, there are all sorts of suggestions for error code 0xC02020C4 and 0xC020844B - a network glitch (that old standby), memory settings, all sorts of things<br />
<br />
What I THINK happened was a problem delivering data to Database B in Azure. And the problem in my case is that the Azure database has been set to 100GB, and I'm trying to put more data than that into it!<br />
<br />
It's a standard Azure DB - so the max size is 250GB. Of course you can get much bigger than that, but it would involve paying Microsoft big bucks. Let's stick to the 250. <br />
<br />
-- *** Note this needs to be run on the MASTER database<br />
ALTER DATABASE [Archive_2019Q34] MODIFY (MAXSIZE = 250GB);<br />
<br />
I suppose that if Azure databases grew of their own accord, I would be bitching about how they grew so big it costs a fortune. It would be nice if SSIS gave us something more meaningful thoughJackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-20798484515673496812020-03-03T06:28:00.002-08:002020-03-03T06:30:28.790-08:00Missing Indexes<br />
<br />
<div style="margin: 0px;">
<span style="font-family: inherit;">Think of a telephone directory</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">It shows everyone in the area, sorted by Surname and
Firstname</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">If it was sorted by phone number, it would take an awfully
long time to find Zachary Young</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">So that’s why it is sorted the way it is</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">A French phone directory is different</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">It’s sorted by Village, then Surname and Firstname</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">In database language, those are two different clustered
indexes.<span style="margin: 0px;"> </span>Clustered just means that the
list of information is sorted that way</span></div>
<br />
<div style="margin: 0px;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhofNZ4E8V1GYuKIRcC1IN1uzB3QruQgBaW6RsGmAmE4DBr9ux8Ap3Xz7a5UMwgmcnjHFwmyAeblmon8kOF3CnTz9Cmt0w434k_CmZhCcTFwRjV-YTkThWcX5gXxLZ-WiSJwnXYRnhZivh7/s1600/midsomer_murders.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="768" data-original-width="960" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhofNZ4E8V1GYuKIRcC1IN1uzB3QruQgBaW6RsGmAmE4DBr9ux8Ap3Xz7a5UMwgmcnjHFwmyAeblmon8kOF3CnTz9Cmt0w434k_CmZhCcTFwRjV-YTkThWcX5gXxLZ-WiSJwnXYRnhZivh7/s400/midsomer_murders.jpg" width="400" /></a></div>
<div style="margin: 0px;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0px;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">But suppose you were Detective Chief Inspector Tom Barnaby,
every week hunting down the killer of half the population of the village of <a href="https://en.wikipedia.org/wiki/Midsomer_Murders" target="_blank">Midsomer</a>.<span style="margin: 0px;"> </span>You found a clue - a phone number scrawled in
the victim’s blood at the murder scene, and wanted to find out whose number it
was.<span style="margin: 0px;"> </span>Yeah, obviously the murderer is
going to turn out to be Zachary Young, but you don’t know that.<span style="margin: 0px;"> </span></span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">Your database query might look something like this:</span></div>
<br />
<div style="margin: 0px;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">select</span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>firstname</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">,</span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>lastname</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">,</span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>address1</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">,</span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>Town</span></div>
<div style="margin: 0px;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">from</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"> </span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>Directory</span></div>
<div style="margin: 0px;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">where</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"> </span></div>
<div style="margin: 0px;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"><span style="margin: 0px;"> </span>PhoneNumber </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt; margin: 0px;">'0123456789'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; margin: 0px;"></span></div>
<br />
<div style="margin: 0px;">
<br /></div>
<br />
<div style="margin: 0px;">
<span style="font-family: inherit;">It’s going to take a long time to run that – because the
directory table is missing an index on PhoneNumber</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">When you run the query, it has to search all the way through
the list of names until eventually it finds a match</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">SQL Server keeps a record of all the queries it runs, and
you can get it to count up all the times it scans through a table because the
index it needs is missing.<span style="margin: 0px;"> </span></span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">So – you REALLY need that missing index.<span style="margin: 0px;"> </span>You will find the murderer eventually, but the
index makes it a lot easier</span></div>
<div style="margin: 0px;">
<span style="font-family: inherit;"></span><br /></div>
<div style="margin: 0px;">
<span style="font-family: inherit;">Create the index, and everything works a whole lot more
easily</span></div>
<br />
<div style="margin: 0px;">
Want something a bit more technical? Here's how to <a href="https://www.sqlservercentral.com/blogs/find-missing-indexes-for-all-sql-server-databases" target="_blank">find the missing indexes</a></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><span style="font-family: "calibri";"></span><span style="font-family: inherit;"></span>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-84914115107256480952020-02-24T06:53:00.000-08:002020-02-24T06:53:56.162-08:00The Joys of Admin
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 24px;">
<i style="mso-bidi-font-style: normal;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">I'm admin on a group on LinkedIn called French Connections – 65,621
members at the time of writing.<span style="margin: 0px;"> </span>The
other day I got a join request to review.<span style="margin: 0px;">
</span>The profile was a little bit thin, and only 15 connections, so I sent a
message…<span style="margin: 0px;"> </span></span></i></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 24px;">
<i style="mso-bidi-font-style: normal;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">But read for yourself.<span style="margin: 0px;"> </span></span></i></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 24px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Monday Jack Whittaker sent the
following message at 12:47 PM </span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">You are both members of <b>French
Connections</b> on LinkedIn </span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Hi Charlie! Thanks for
applying to join the French Connections group! I have a slight problem - we
like members to have some sort of connection to Francophonie (it helps to keep
spammers at bay), and unfortunately you don't seem to have one. Probably
because you haven't added it to your profile yet, or possibly I just missed it!
Perhaps you live in France? Drive a Peugeot? Love French cuisine?
Please reply and tell me why you would like to join, and if it’s appropriate,
add it to your profile. Do please let me know within a few days or I’ll assume
you aren’t interested. I look forward to hearing from you Regards Jack
Whittaker Moderator</span></div>
<br />
<ul type="disc">
<li style="color: black; font-family: "Times New Roman","serif"; font-size: 12pt; font-style: normal; font-weight: 400; line-height: normal; margin: 0px 0px 13.33px;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Today Charlie O sent the following messages at 3:30 PM </span></li>
</ul>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">You are totally wrong in your
assumptions. first of all i am Belgian and Flemish which speaks french
and 12 other languages secondly i lived in nice france for 5 years even
got married to my first wife in Nice But your reaction as a moderator
says it alll Forget about me and be less biased next time. little
bonafide Ape. I know more about france and the culture it stand for then
you ever will. You missed a golden opportunity and cant even write french
I bet. SO, dear wanker: au revoir, Le Petit Pois Un grand salut du LION
Flament, which would gobble up little minded Brits or Yankess for breakfast.
You must have nothing but 'faux' wannabees trying to understand what I did a
long time ago in your group. I was willing to help you learn about what
you claim interest you. Learn to do proper research and get an education
upgrade in social communication on this type of platform you badly need dear
FOOL. Carpe Diem, I rest my case Dear Moderator you are now
challenged and I will make sure the public at large knows how biased you are
....</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">And you do not dictate what
goes on or comes off my profile dear fool!</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;"> </span><i style="mso-bidi-font-style: normal;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;"><Charlie O sends me a link to his brother’s Linkedin profile for no
obvious reason – to spare his brother's blushes, I’ve removed it from this transcript></span></i></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">my brother would slpa you for
saying what you said to me, shall I prosecute you in a court room?</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Dumb fool</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Moderate that, Mr Le
Professuer de math qui est devenue un venduer de petit pois!</span></div>
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<br /></div>
<br />
<ul type="disc">
<li style="color: black; font-family: "Times New Roman","serif"; font-size: 12pt; font-style: normal; font-weight: 400; line-height: normal; margin: 0px 0px 13.33px;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Jack Whittaker sent the following message at 3:34 PM </span></li>
</ul>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<a href="https://www.linkedin.com/in/jackwhittaker/"><span lang="EN" style="color: blue; font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Jack
Whittaker</span></a><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;"> 3:34 PM </span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Hi Charlie None of that stuff
appears in your profile Any one of those things would have got you welcomed to
the group without question - but I'm not psychic So - let's assume you are
having a bad day - would you still like to join or have I offended you too
much?</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<br /></div>
<br />
<ul type="disc">
<li style="color: black; font-family: "Times New Roman","serif"; font-size: 12pt; font-style: normal; font-weight: 400; line-height: normal; margin: 0px 0px 13.33px;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Charlie O sent the following messages at 3:35 PM </span></li>
</ul>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">People like me are protecting
what you can find out about me for good reasons as is proven yet again!!!</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Lets assume you dont know
google exsist A simple charlie o would have answered all your dumb questions</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">learn to do your job as a
moderator you dumb ape</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">now leave me be and stop
wasting my time with your spam pre created paragraphs</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">No one wil tell me what to put
on a profile Unlike you I dont need this linkedin app or site to achiev what I
achieved in lifeI was trying to help your group You dumb fool which means I am
the good kind of apple you kicked in the balls, bravo fool! ILL GLADLY TAKE
SOME TIME NOW TO DOCUMENT THIS ON SOCIAL MEDIA AND MAKE YOUR ATITUDE GO VIRAL</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Lets see how you deal with
that as a moderator and my internet foot print is huge and I know how to SEO
the right way ...</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Skills which will garantee
your group gets seen as it needs to be seen a bunch of wankers from the UK
trying to make french clients or contacts!!!</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">No smart come backs I see you
are a coward as well?</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Last but no0t least you should
never have been made a moderator ... you haven't got the skills for the role!</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">lets see where this ape works
and if i have him as client if so your company will be booted off the
books</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">sql dba admin what a joke</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Do you even speak french ape? <i><enough to know how to spell "vendeur"></i></span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Brexit YES voter I bet ....</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">grow up fool!</span></div>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<br /></div>
<br />
<ul type="disc">
<li style="color: black; font-family: "Times New Roman","serif"; font-size: 12pt; font-style: normal; font-weight: 400; line-height: normal; margin: 0px 0px 13.33px;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">Jack Whittaker sent the following message at 3:49 PM </span></li>
</ul>
<br />
<div style="line-height: normal; margin: 0px 0px 13.33px 48px;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; margin: 0px;">You seem to be slightly upset
Charlie All because I asked a man who lives in Sheffield if he has any
connection to francophonie I'm curious - why do you feel that I insulted you?</span></div>
<br />
<div style="margin: 0px 0px 13.33px;">
<br /></div>
<br />
<div style="margin: 0px 0px 13.33px;">
<i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">Sadly, Charlie O never
replied</span></i></div>
<br />
<div style="margin: 0px 0px 13.33px;">
<i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">I blocked him from the
group, of course – well, obviously</span></i></div>
<br />
<div style="margin: 0px 0px 13.33px;">
<i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">But I took his advice
and googled his name.<span style="margin: 0px;"> </span>I found his
Facebook account – and it’s chock full of adverts for all sorts of crap.<span style="margin: 0px;"> </span>Remember this line in my initial message to
him?<span style="margin: 0px;"> </span>“</span></i><i style="mso-bidi-font-style: normal;"><span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%; margin: 0px;">We like members to have some sort of connection
to Francophonie (it helps to keep spammers at bay)”.<span style="margin: 0px;"> </span>Turns out he IS a spammer!</span></i></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com1tag:blogger.com,1999:blog-2139762005134795152.post-23403086451588973702020-02-20T04:15:00.002-08:002020-02-20T04:15:14.706-08:00Activity Group not synchronizing<span style="font-family: Calibri;">There was an activity
group failover in the night.<span style="margin: 0px;"> </span></span><span style="font-family: Calibri;">Some sort of glitch –
glitch happens.<span style="margin: 0px;"> </span></span><span style="font-family: Calibri;">The Primary flicked over
to the Secondary and the Secondary became the Primary, no problem</span>. <br /><span style="font-family: Calibri;">The Old Primary became
the Secondary<br /></span><span style="font-family: Calibri;">BUT…<br /></span><br />
<span style="font-family: Calibri;">Databases on the New
Secondary are marked as Not Synchronizing</span><br />
<br />
<div style="line-height: normal; margin: 0px;">
<br /></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ12RNdUCXlkmgIuIu06bhHhWDVas6WCY4QI5_xz88rbSu9muVqdEW04A7tJWNfbR0Of1aVFzEAAIfTZ9bnVLKfPKSI8ydmQRPG3stGUBQjtsCrB6BeJcFcXTUB8p9_XKMLvaLlryBZ1hz/s1600/Not+Synchronizing.png" imageanchor="1" style="-webkit-text-stroke-width: 0px; background-color: transparent; color: #0066cc; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-left: 16px; margin-right: 16px; orphans: 2; text-align: center; text-decoration: underline; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><img border="0" data-original-height="563" data-original-width="1116" height="321" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ12RNdUCXlkmgIuIu06bhHhWDVas6WCY4QI5_xz88rbSu9muVqdEW04A7tJWNfbR0Of1aVFzEAAIfTZ9bnVLKfPKSI8ydmQRPG3stGUBQjtsCrB6BeJcFcXTUB8p9_XKMLvaLlryBZ1hz/s640/Not+Synchronizing.png" width="640" /></a><br />
<br />
The e<span style="font-family: Calibri;">rror log says: </span><span style="font-family: Calibri;">A connection timeout has
occurred on a previously established connection to availability replica with id
[5FA3CBDB-5504-43E2-8697-2C713110307B].<span style="margin: 0px;">
</span>Either a networking or a firewall issue exists or the availability
replica has transitioned to the resolving role.<br /></span><br />
<span style="font-family: Calibri;">Well, the replica has certainly transitioned.<span style="margin: 0px;"> </span>Other instances on the nodes were unaffected</span><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><span style="font-family: Calibri;"></span><br />
<br />
<div style="margin: 0px 0px 13.33px;">
<span style="font-family: inherit;">A bit of googling finds <a href="https://support.microsoft.com/en-gb/help/3213703/fix-an-always-on-secondary-replica-goes-into-a-disconnecting-state" target="_blank">this article</a>. <br /><i>Microsoft recommends restarting service on secondary replica. <br /><span style="color: black; line-height: 115%; margin: 0px;">The problem occurs because of an <a href="https://support.microsoft.com/en-gb/help/317723/description-of-race-conditions-and-deadlocks" target="_blank">internal race condition</a>.</span></i><span style="margin: 0px;"> </span>What on earth
does that mean? Ah - it's a bit like a deadlock. </span><span style="font-family: Calibri;"><br /></span></div>
<div style="margin: 0px 0px 13.33px;">
And <a href="https://techcommunity.microsoft.com/t5/sql-server-support/availability-group-database-reports-not-synchronizing-recovery/ba-p/319034" target="_blank">another article</a>. <br /><span style="font-family: inherit;"><i><span style="color: #333333; margin: 0px;">Resolve Secondary Replica Database
Not Synchronizing </span><span style="color: #333333; line-height: 115%; margin: 0px;">You cannot ONLINE a secondary replica availability group database<b> </b></span><span style="color: #333333; line-height: 115%; margin: 0px;">Since a secondary replica availability group database is really in an
ongoing restoring state, it cannot be set Online like the primary replica.
Remember it is already in the Online role, according to the DMVs. </span></i></span><span style="color: #333333; line-height: 115%; margin: 0px;"><br /></span></div>
<span style="font-family: inherit;"><i><span style="color: #333333; line-height: 115%; margin: 0px;">
<br />
<b>Solution </b></span><span style="color: #333333; line-height: 115%; margin: 0px;">Restart the SQL Server
instance hosting the secondary replica. This will initiate recovery on all
databases including availability group databases, and so long as SQL Server can
access all the database files, the availability group database affected should
recover successfully and resume synchronization with the primary replica. </span></i></span><br />
<span style="font-family: inherit;">OK, that all seems pretty clear. <br /><br />Next question - can we do it now? In the working day? </span><br />
Well, if we don't, we have lost our Availability group resilience - that's not a Good Thing<br />
<br />
If you look at the picture above, we have an estimated recovery time of 0 seconds. I've added a few extra columns to my Dashboard - there's a<span style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Calibri; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> <a href="https://sqlperformance.com/2015/08/monitoring/availability-group-replica-sync" target="_blank">list of them here<span style="color: #b00000; font-family: Times New Roman;">. </span></a><span style="font-family: inherit;"></span><span style="color: black;"></span></span>Now that seems too good to be true. It's been down for a few hours, are you seriously expecting me to believe that there is no data waiting to go across to the Secondary? <span style="font-family: inherit;">Pshaw! I say to you. <br /></span><span style="font-family: inherit;"><span style="color: black;"><span style="margin: 0px;">One of my colleagues thinks that
Dave has mentioned this issue before – but he isn’t sure.<span style="margin: 0px;"> </span></span><span style="margin: 0px;">Dave is on holiday - because of course he is. Whenever you need someone who knows stuff, Sod's Law mandates that they are not around. </span></span></span><br />
<div style="margin: 0px 0px 13.33px;">
</div>
<div style="margin: 0px 0px 13.33px;">
<span style="margin: 0px;"><span style="font-family: inherit;"><span style="color: black;">So we are a bit scared of
restarting the services on the secondary – is it going to impact on the primary
as it catches up with the backlog of stuff to be transferred?<span style="margin: 0px;"> </span></span></span></span></div>
<div style="margin: 0px 0px 13.33px;">
</div>
<div style="margin: 0px 0px 13.33px;">
<span style="margin: 0px;"><span style="font-family: inherit;"><span style="color: black;">We decide to wait until everyone
goes home for the night.<span style="margin: 0px;"> </span></span></span></span></div>
<div style="margin: 0px 0px 13.33px;">
</div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">I stop the agent service.<span style="margin: 0px;"> </span></span></div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">I stop the SQL Server service</span></div>
<div style="margin: 0px 0px 13.33px;">
</div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">I start the SQL Server service.<span style="margin: 0px;"> </span></span></div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">I start the Agent service</span></div>
<div style="margin: 0px 0px 13.33px;">
</div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">I go and have a look at the Dashboard</span></div>
<span style="font-family: inherit;"></span><span style="color: black;"></span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeHJxjgrq4pSTF6PXcOp-_Y2AOzkIz6L-jUEQ3gpUqwWb5YOpmctK0H4PsKdikd00hWAjFmC4tSLw8O_CxVz09Yzs0D9v5o3uECLcM-oJ7nmJiLUrbkFKJZ3S6kp6_LIsx37FnCrV34AjU/s1600/Synchronizing.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="555" data-original-width="1243" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeHJxjgrq4pSTF6PXcOp-_Y2AOzkIz6L-jUEQ3gpUqwWb5YOpmctK0H4PsKdikd00hWAjFmC4tSLw8O_CxVz09Yzs0D9v5o3uECLcM-oJ7nmJiLUrbkFKJZ3S6kp6_LIsx37FnCrV34AjU/s640/Synchronizing.png" width="640" /></a><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="margin: 0px 0px 13.33px;">
<span style="color: black; font-family: inherit;">The two small databases have already sorted themselves out. </span></div>
<div style="margin: 0px 0px 13.33px;">
<span style="font-family: inherit;"><span style="color: black;">The two big ones estimate 20 minutes and 10 minutes to
recover, but it quickly becomes obvious that this is an over-estimate.<span style="margin: 0px;"> </span>The actual time taken to recover was about 3 mins
for the larger, 1 min for the smaller.<span style="margin: 0px;"> There doesn't appear to have been any impact on the Primary, but it fixed itself before I could check. </span></span></span></div>
<div style="margin: 0px 0px 13.33px;">
<span style="margin: 0px;"><span style="font-family: inherit;"><span style="color: black;">When Dave returns from his hols he confirms that restarting
the services on the secondary will fix this; it takes seconds he says.<span style="margin: 0px;"> </span>He reports that it sometimes happens when
he manually fails over e.g. to apply patches.<span style="margin: 0px;">
</span>Out of hours, of course.<span style="margin: 0px;"> </span></span></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
So with hindsight, I would feel much more confident about restarting the service on the Secondary node, and do it in the working day rather than run the risk of losing data. </div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-47421290803066588962019-03-29T04:06:00.001-07:002019-03-29T09:30:41.080-07:00Shrinking that Database<b><span style="font-size: large;">Rule 1 - don't shrink that database!</span></b><br />
<b></b><span style="font-size: large;"></span><br />
It's a bad thing to do. <a href="https://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/" target="_blank">Brent Ozar says so.<span style="color: #b00000;"> </span></a> And I believe him,. Really, it's a bad idea<br />
<br />
Imagine the stock control database.<br />
You buy widgets, you sell widgets<br />
100 widgets into stock<br />
80 widgets out<br />
No need to free up the disk space, because the day after, you are going to add another hundred widgets. <br />
And SQL Server <b>doesn't</b> free up the space. It just sits there waiting for more widgets<br />
<br />
There's a but coming. <br />
<div>
<br /></div>
<div>
But suppose you <b>need</b> to free up space? In my situation, I purged the database of two million old records into an archive DB. Now I have an archive DB taking up 150 GB. The original DB contains only 10,000 records (the last 15 days) but it still takes up 150GB, with 140GB free. There's no room on the disk, and the Infrastructure guys aren't keen on giving me any more because it is an old physical box and it would mean them actually doing some work for a change. </div>
<div>
<br /></div>
<div>
No problem, I can do this</div>
<div>
<br /></div>
<div>
I set up a maintenance plan:</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj27MFMiCL95_C1fZTwsyZ0uhB3_XLHY6F0EzfMNxW5Hkir-e4Hx6rxH0lBMB6jKEbqC4Y6K9KHy-yy72sxQaYUJVAbwDhzc4eNIFlMzeUq7c66pVAlT2SIvmDlpsUU8GYuh4am2BzLU4OA/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="728" data-original-width="910" height="512" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj27MFMiCL95_C1fZTwsyZ0uhB3_XLHY6F0EzfMNxW5Hkir-e4Hx6rxH0lBMB6jKEbqC4Y6K9KHy-yy72sxQaYUJVAbwDhzc4eNIFlMzeUq7c66pVAlT2SIvmDlpsUU8GYuh4am2BzLU4OA/s640/Capture.PNG" width="640" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Doing it as a maintenance plan lets me specify a time out for each step, which saves me the task of coding it. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Step 1 - Shrink it in manageable chunks</div>
<div class="separator" style="clear: both; text-align: left;">
Rather than try and shift all that 140GB empty space in one go, I want to shift a bit at a time, rather like a batch <a href="https://social.technet.microsoft.com/Forums/en-US/1abc8cef-a28a-42ce-ad97-635bdcc2c639/proper-way-to-stop-dbcc-shrinkfile?forum=transactsql" target="_blank">Anil Kumar sets out a way to do it, and I unashamedly stole his code</a></div>
<div class="separator" style="clear: both; text-align: left;">
How big a chunk? Doesn't really matter - 512MB seemed like a good figure. The point is that it shrinks. then shrinks, then shrinks again. If it fails for some reason e.g. hits the time out, then you have done at least a few of the chunks. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="-webkit-text-stroke-width: 0px; background-color: transparent; clear: both; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
Step 2 - Release Space</div>
<div class="separator" style="-webkit-text-stroke-width: 0px; background-color: transparent; clear: both; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
Just in case it hasn't gone already, belt and braces</div>
<div class="separator" style="-webkit-text-stroke-width: 0px; background-color: transparent; clear: both; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
USE DatabaseName</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
GO</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
DBCC SHRINKFILE (N'FileName' , 0, TRUNCATEONLY)</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
GO</div>
<div class="separator" style="-webkit-text-stroke-width: 0px; background-color: transparent; clear: both; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;" /></div>
<div class="separator" style="clear: both; text-align: left;">
Step 3 - Smart Rebuild</div>
<div class="separator" style="clear: both; text-align: left;">
All that shrinking is going to screw up your fragmentation levels something 'orrible. </div>
<div class="separator" style="clear: both; text-align: left;">
Bad, really bad. for performance. </div>
<div class="separator" style="clear: both; text-align: left;">
If Brent Ozar catches you, he will not be a happy bunny</div>
<div class="separator" style="clear: both; text-align: left;">
So we need to Rebuild or Reorganize the indexes. </div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.mssqltips.com/sqlservertip/4470/script-to-manage-sql-server-rebuilds-and-reorganize-for-index-fragmentation/" target="_blank">Here's how</a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
All clear?</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Right then. So I fire it off, it runs, step 1 times out as expected, the other two steps run, all well and good. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Except that the database hasn't shrunk. Not one MB less. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I spent a lot of time with my friend Google, and I see lots of people are having similar issues, hence this blog, which I hope will help others. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I set up a bare minimum job to shrink the database a little bit:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
USE DatabaseName</div>
GO<br />
DBCC SHRINKFILE (N'FileName' , 180176)<br />
GO<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I set it running, and went home. Came in next day, and it had succeeded - Two hours 45 minutes, and it shaved 6.5GB off the database! (That IS a little bit, when you have a 190GB database). And that is a much longer time than I allowed for in my timeout period. I reduced the target and ran it again - again it succeeded, this time removing 10GB in 03:37:40</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I'm not sure why shrink in the manageable chunks code didn't work; it's on my list to troubleshoot that. But in the meantime I will be able to live with a rough and ready shrink that works. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />
<u></u><b></b>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-65119867771368223282019-01-07T09:23:00.000-08:002019-01-08T01:22:14.538-08:00Understanding Unique ConstraintsI'm looking at a database from a vendor, who shall be Nameless. <br />
<br />
It contains a table called tblConfig. OK, I know some people hate to see tables with the prefix tbl, but I can see the point to it. That isn't my issue<br />
<br />
I'm reviewing indexes, with a view to getting rid of duplicates. There really is no point in having two indexes doing the same thing - SQL Server will only use one of them, but it has to keep both updated.<br />
<br />
And that's where I found it:<br />
<br />
There is an index on that table called <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">UniqueConstraint. </span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">There is another index, also called <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">UniqueConstraint. </span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">One is unique, the other isn't, which is how the developer got away with it. </span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-variant: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-variant: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-variant: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-variant: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The index UniqueConstraint which is unique indexes different fields to its namesake <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">index UniqueConstraint</span> which is not unique. </span></span></span></span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-variant: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
</span><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">There is also an index called <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">UniqueConstraintReporting. This duplicates the index UniqueConstraint which is not unique. <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">UniqueConstraintReporting is unique.</span></span></span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">I've dropped the UniqueConstraint index which is not unique, leaving me with the unique indexes UniqueConstraint and <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">UniqueConstraintReporting </span></span></span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">I hope that is all clear to everyone?</span></span></span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<br />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 494px;"><colgroup><col style="mso-width-alt: 17550; mso-width-source: userset; width: 370pt;" width="494"></col></colgroup><tbody>
<tr height="19" style="height: 14.4pt;"><td height="19" style="background-color: transparent; border: 0px rgb(0, 0, 0); height: 14.4pt; margin: 0px; width: 370pt;" width="494"></td></tr>
<tr height="19" style="height: 14.4pt;"><td height="19" style="background-color: transparent; border: 0px rgb(0, 0, 0); height: 14.4pt; margin: 0px;"></td>
</tr>
</tbody></table>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-37469322279036486802018-10-23T09:27:00.001-07:002018-10-23T09:35:22.026-07:00In Search of a Smarter Maintenance PlanI wrote a blog post about <a href="http://dbatasks.blogspot.com/2012/12/implementing-maintenance-plans.html" target="_blank">Implementing Maintenance Plans</a> a while back. In it I suggested that if you have time to rebuild the indexes once a week, you should go ahead and do it. <br />
<br />
But what if you DON'T have time?<br />
<br />
<b>Indexes</b><br />
<b></b><br />
I suggested rebuilding the indexes once a week. And the bog standard maintenance plan rebuilds every index, whether it needs it or not. But if things are heavily fragmented, or there are a lot of indexes with millions of rows each, that might take an awfully long time. <span style="font-family: "calibri";">I would expect heavily fragmented indexes to adversely affect performance, so set up a Smart Rebuild / Reorganise job to run as part of the weekly maintenance plan. </span><br />
<span style="font-family: "calibri";"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6Acql59eif4BG-PFrEcA-dTniQgLgxuhuvs1z1Iq-yIslYTztiL3QOJMfkeSjX_MlHNFcT24XfFXjQ3mPLIq9ZKQPxoH4VZacXRYnzggyTfqZDXBpfB0Vn2fUPu8HvFEQd4EpbZ7PN78S/s1600/weekly.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="691" data-original-width="802" height="550" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6Acql59eif4BG-PFrEcA-dTniQgLgxuhuvs1z1Iq-yIslYTztiL3QOJMfkeSjX_MlHNFcT24XfFXjQ3mPLIq9ZKQPxoH4VZacXRYnzggyTfqZDXBpfB0Vn2fUPu8HvFEQd4EpbZ7PN78S/s640/weekly.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Instead of the usual Rebuild Index task, grab the Execute T-SQL Statement and add it to the maintenance plan. You can restrict the run time with the Execution Time Out parameter - specifying 3600 seconds means that after an hour the job fails, <span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">so that
it does not over-run the maintenance window. Note that if it hits that time out, the job will fail, so I have put this step last. It will also send an error message email if you have it set up to do so. </span><br />
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaQU-xMlqHKy5Xc1NW56kD08rqW-81lmEpq6iN-wd8rmXUvJ20Vnrx-TbhZpz2nZmrQ-iCatSV_7SCRc1-lWgQnYUNDOD3dF5Mupz_WgMP582x90pWlwIciwRTQlA_8OQKs9GW4PU1ZFq5/s1600/Task.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="525" data-original-width="705" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaQU-xMlqHKy5Xc1NW56kD08rqW-81lmEpq6iN-wd8rmXUvJ20Vnrx-TbhZpz2nZmrQ-iCatSV_7SCRc1-lWgQnYUNDOD3dF5Mupz_WgMP582x90pWlwIciwRTQlA_8OQKs9GW4PU1ZFq5/s400/Task.png" width="400" /></a></div>
<br />
<a href="https://www.mssqltips.com/sqlservertip/4470/script-to-manage-sql-server-rebuilds-and-reorganize-for-index-fragmentation/" target="_blank">Here's the script</a> - I swiped it from <a href="https://www.mssqltips.com/sqlserverauthor/183/artemakis-artemiou/">Artemakis Artemiou</a> - poli efcharisto! <b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">The job identifies all the indexes with fragmentation levels
>15%</span></div>
<span style="font-family: "calibri";">It starts with the worst and works down</span><br />
<span style="font-family: "calibri";">Above 30% it rebuilds them</span><br />
<span style="font-family: "calibri";">Between 15% and 30% it re-organises them</span><br />
<br />
If the database is badly fragmented, you might want to run this daily, at least until they are under control. <br />
<br />
<br />
<b>Statistics</b><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">I also set up a job to update statistics. Statistics can get out of
date, and queries may be less efficient because of this. </span></div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Updating statistics is a bit of a funny one. If you rebuild the indexes, you get a nice new set of statistics. But if we are not rebuilding the indexes, you have to rely on Microsoft to do it as it thinks fit, <a href="https://blogs.msdn.microsoft.com/srgolla/2012/09/04/sql-server-statistics-explained/" target="_blank">according to its algorithm</a>. Sod's Law says that it won't update the ones you want it to update. The SQL execution plan can ignore a perfectly good index because the statistics are not up to date, and may take far longer to run a query because of this. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8heakFGr15ZV1qVYvC_eVMtg6nxxyeBxGau4wVO-p1dcFPzYLp84tOgQOSkGXUJXpDl_K7bDj2tFIjRPbqhBFYlVwand-lyh6e1EJvUfMEulfahDzs-mGCMgqihZd5GVI0U2vva2ejl5Z/s1600/statistics.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="854" data-original-width="1069" height="508" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8heakFGr15ZV1qVYvC_eVMtg6nxxyeBxGau4wVO-p1dcFPzYLp84tOgQOSkGXUJXpDl_K7bDj2tFIjRPbqhBFYlVwand-lyh6e1EJvUfMEulfahDzs-mGCMgqihZd5GVI0U2vva2ejl5Z/s640/statistics.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
As before, I added a T-SQL task to the Daily tasks, last in the line. </div>
<div class="separator" style="clear: both; text-align: left;">
I've given it a timer limit of 5400 seconds (an hour and a half, to save you getting your calculator out)</div>
<div class="separator" style="clear: both; text-align: left;">
And it runs a stored procedure which I found <a href="http://billg.sqlteam.com/2010/12/02/script-to-update-statistics-with-time-window/" target="_blank">here</a>...</div>
<div class="separator" style="clear: both; text-align: left;">
Thanks to <a href="https://billg.sqlteam.com/author/bill-graziano/" target="_blank">Bill Graziano</a>!</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmx18qw30SaWtplE5ZVhzR8HTqy0giaaYwDtTT_pIc7Atxu7-zocWio-aTIvxpYhNyAoeCGvLg_1Efp1Ylv3xcZ_Mn_OM6iW_kf_Me1LG13hdu7PSPvAGYKLXjTYbxF4iVbhkkLuD9gYRl/s1600/stats+task.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="525" data-original-width="705" height="476" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmx18qw30SaWtplE5ZVhzR8HTqy0giaaYwDtTT_pIc7Atxu7-zocWio-aTIvxpYhNyAoeCGvLg_1Efp1Ylv3xcZ_Mn_OM6iW_kf_Me1LG13hdu7PSPvAGYKLXjTYbxF4iVbhkkLuD9gYRl/s640/stats+task.png" width="640" /></a></div>
<br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike></div>
Note that Bill's script sets a time limit too, so I don't <u>really</u> need to set an execution timeout.<br />
<br />
There's an alternative to the above - the well regarded and reputable <a href="https://ola.hallengren.com/" target="_blank">scripts from Ola Hallengren</a>. <br />
A lot of people swear by them. <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com1tag:blogger.com,1999:blog-2139762005134795152.post-23242124580852480232018-10-17T07:04:00.000-07:002018-12-13T06:56:23.057-08:00The Madness Continues<br />
I have a script which identifies MDF files which do not appear in my list of databases.<br />
<br />
The purpose of this is to find databases, usually on development boxes, which have been detached and forgotten, but are taking up space on the disk. A detached database is of course invisible, unless you go poking around looking for it. <br />
<br />
What I usually do is:<br />
i) attach them again<br />
ii) take a final backup just in case they actually are needed<br />
(not very likely, but sod's law says if you don't do this, they will suddenly become critical) <br />
iii) drop the thing<br />
<br />
But today, I failed at the first hurdle:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL_IE3rD8kogQucuz7-Z_RsbJ0Likiosv_IlRyjPFIcuzKElw-38pzunroaQaR2_Zqcc_wrk6ZgBjWCzydD7N1hWcbEbEZbKLxNmAGfgxftLTJu89nx3B40d5CHnMUPEvk1jiGD8L_JW1k/s1600/ERROR+MESSAGE2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="231" data-original-width="643" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL_IE3rD8kogQucuz7-Z_RsbJ0Likiosv_IlRyjPFIcuzKElw-38pzunroaQaR2_Zqcc_wrk6ZgBjWCzydD7N1hWcbEbEZbKLxNmAGfgxftLTJu89nx3B40d5CHnMUPEvk1jiGD8L_JW1k/s400/ERROR+MESSAGE2.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Create file encountered <a href="https://documentation.red-gate.com/sbu7/errors-and-warnings/other-errors/system-error-32-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process" target="_blank">operating system error 32</a><br />
<br />
<div>
The process cannot access the file because it is being used by another process</div>
<div>
<br /></div>
<div>
<a href="http://sqltechtips.blogspot.com/2015/12/fix-attach-database-error-5123.html" target="_blank">SQL Server error 5123</a> tells me it's a problem attaching the database</div>
<div>
<br /></div>
<div>
Huh? It's a detached database file, isn't it? </div>
<div>
What could possibly be using the detached file?<br />
<br /></div>
<div>
Some utter maniac renamed the .ldf file as .mdf<br />
<br /></div>
<div>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 782px;">
<colgroup><col style="mso-width-alt: 3896; mso-width-source: userset; width: 82pt;" width="110"></col>
<col style="mso-width-alt: 1308; mso-width-source: userset; width: 28pt;" width="37"></col>
<col style="mso-width-alt: 10552; mso-width-source: userset; width: 223pt;" width="297"></col>
<col span="2" style="mso-width-alt: 2190; mso-width-source: userset; width: 46pt;" width="62"></col>
<col style="mso-width-alt: 3498; mso-width-source: userset; width: 74pt;" width="98"></col>
<col style="mso-width-alt: 1934; mso-width-source: userset; width: 41pt;" width="54"></col>
<col style="mso-width-alt: 2190; mso-width-source: userset; width: 46pt;" width="62"></col>
</colgroup><tbody>
<tr height="19" style="height: 14.4pt;">
<td height="19" style="background-color: transparent; border: 0px rgb(0, 0, 0); height: 14.4pt; margin: 0px; width: 82pt;" width="110"><b><span style="font-family: "calibri";">name</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 28pt;" width="37"><b><span style="font-family: "calibri";">fileid</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 223pt;" width="297"><b><span style="font-family: "calibri";">filename</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 46pt;" width="62"><b><span style="font-family: "calibri";">filegroup</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 46pt;" width="62"><b><span style="font-family: "calibri";">size</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 74pt;" width="98"><b><span style="font-family: "calibri";">maxsize</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 41pt;" width="54"><b><span style="font-family: "calibri";">growth</span></b></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px; width: 46pt;" width="62"><b><span style="font-family: "calibri";">usage</span></b></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td height="19" style="background-color: transparent; border: 0px rgb(0, 0, 0); height: 14.4pt; margin: 0px;"><span style="font-family: "calibri";">GenDraft</span></td>
<td align="right" style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">1</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">F:\User Databases\GenDraft_20180925.mdf</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">PRIMARY</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">40960 KB</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">Unlimited</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">8192 KB</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">data only</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td height="19" style="background-color: transparent; border: 0px rgb(0, 0, 0); height: 14.4pt; margin: 0px;"><span style="font-family: "calibri";">GenDraft_log</span></td>
<td align="right" style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">2</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">G:\Logs\GenDraft_20180925<span style="color: red; margin: 0px;">.mdf</span></span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">NULL</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">12352 KB</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">2147483648 KB</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">4096 KB</span></td>
<td style="background-color: transparent; border: 0px rgb(0, 0, 0); margin: 0px;"><span style="font-family: "calibri";">log only</span></td>
</tr>
</tbody></table>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br /></div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-52872788572337765602018-08-16T09:12:00.000-07:002018-08-16T09:14:32.273-07:00Database Sizes and Growth RatesI've been asked to write a few words about this thrillingly sexy topic. Why? Because I've been looking at some existing servers and finding quite a few issues which are Bill's Fault.<br />
<br />
Microsoft thinks that a good initial size for a database is 1MB, and it should grow by 1MB every time it grows. Logs should grow by 10%, which isn't utterly mad, but isn't a good idea either. Since Microsoft sets these defaults, it's easy to set up a database. Which is good. But since they are lousy defaults, it's bad.<br />
<br />
I suppose these figures are there because there is no right answer to the question "How big should these settings be then, Mr Smartypants DBA?". <br />
<br />
So what's the problem?<br />
<br />
Well, I recently found a database which had grown from 500MB to 11071MB in 1MB increments. That's a LOT of growth events. Each time it grows, it has to stop and think about it. And if it has to grow ten times, that's a lot of hanging around, twiddling your thumbs, waiting for it to think. <br />
<br />
Hindsight is a wonderful thing. I set that database to grow in 512MB increments. Because I now know how big it is, and how big it was when it started. <br />
<br />
In a perfect world, you would carefully calculate how big the database is likely to be after a year or two of adding data, and size it to that size, plus maybe 10% for luck. In the real world, you rely on SQL Server's capacity to grow when it needs to. <br />
<br />
So what's wrong with growing by a percentage? <br />
<br />
First answer: Small database, growing by 10% each time, not a big issue. Big database, growing by 10% each time, maybe 10GB every time it grows, is going to take a long time!<br />
Second answer: Log files are composed of Virtual Log Files (VLFs) and ideally you don't want huge numbers of them, all different sizes - which they will be if they keep growing by 10% at a time. <br />
<br />
And if you forced me to set a default growth rate without knowing anything about the database, I would choose 16MB for the data, 8MB for the logs. Better than Microsoft's default values, anyway. That's what I put in the MODEL database. Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-77599202335659808082018-08-10T07:36:00.000-07:002018-12-21T02:13:59.782-08:00Login Failed on Named Instance<br />
<br />
<div style="margin: 0cm 0cm 0pt;">
I have a SQL Server 2016 server – call it Gandalf</div>
<br />
<div style="margin: 0cm 0cm 0pt;">
There are three instances – Default, Frodo, and Sam</div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Every day I check the error logs. Every day I see that someone or something is trying to log in at 0200. </div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Error: 18456, Severity: 14, State: 5. <br />
Login failed for user ‘agent_default'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>] -</div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
And on Sam, Login failed for user ‘agent_default' and Login failed for user ‘agent_Frodo'</div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Microsoft's <a href="http://www.sqldbadiaries.com/2010/10/24/syspolicy_purge_history-what-is-it/" target="_blank">syspolicy_purge_history </a>job runs every night at 0200 on every
instance.<span style="mso-spacerun: yes;"> </span>It always succeeds. But it is the only SQL Server agent job that runs at 0200. So it must be that, surely? I change it to run at 0215. Next day, the error log says that our mysterious friend attempted to log in at 0200. </div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Hmm, not that then. Is it an automated scan from our white hat penetration testing server? I wasted a lot of time trying to pin this down until I was able to find confirmation that Nope - it is not set up to look on Gandalf. </div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
And then suddenly I noticed that the login attempt had happened at 0215, not 0200. It IS syspolicy_purge_history ! But it is the job on the OTHER instance which is causing the problem. </div>
<span style="font-family: "calibri";"></span><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<span style="font-family: "calibri";">
</span>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<span style="font-family: "calibri";">
<div style="margin: 0cm 0cm 0pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;">1)<span style="font: 7.0pt "Times New Roman";">
</span></span></span>When the job
runs on the Frodo instance, no issues</div>
<div style="margin: 0cm 0cm 0pt;">
</div>
<div style="margin: 0cm 0cm 0pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;">2)<span style="font: 7.0pt "Times New Roman";">
</span></span></span>When the job runs on the default instance, the error
log on Frodo says Default agent account failed to log in - <br />
Error: 18456, Severity: 14, State: 5. <br />
Login failed for user ‘agent_default'. Reason: Could not find a login matching
the name provided. [CLIENT: <local machine>] -</div>
<div style="margin: 0cm 0cm 0pt;">
</div>
<div style="margin: 0cm 0cm 0pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;">3)<span style="font: 7.0pt "Times New Roman";">
</span></span></span>When the job runs on the Sam instance, the error
logs on Default and Frodo says <br />
Login failed for user ‘agent_default' and <br />
Login failed for user ‘agent_Frodo'</div>
</span><br />
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
If you check out that job, Step 3 is running a chunk of Powershell. It gets the Instance name and runs a task to erase records (older than the specified number of days). </div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
<i><span style="font-size: x-small;">if ('$(ESCAPE_SQUOTE(INST))' -eq 'MSSQLSERVER') {$a =
'\DEFAULT'} ELSE {$a = ''};</span></i></div>
<div style="margin: 0cm 0cm 0pt;">
<i><span style="font-size: x-small;">(Get-Item
SQLSERVER:\SQLPolicy\$(ESCAPE_NONE(SRVR))$a).EraseSystemHealthPhantomRecords()</span></i></div>
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<div style="margin: 0cm 0cm 0pt;">
Except that it also looks on all the other instances. And because I have a different service account for each instance, it fails to find a login, which is why the job succeeds on each instance, but the other instance records a failed login attempt!</div>
<div style="margin: 0cm 0cm 0pt;">
</div>
<div style="margin: 0cm 0cm 0pt;">
It's a <a href="https://dba.stackexchange.com/questions/159482/sql-server-login-failure-every-day-at-same-time-with-the-service-account%20Known%20bug%20with%20powershell%20looking%20in%20ALL%20instances" target="_blank">known bug</a> with Powershell, apparently. And that link gives me the Powershell code to fix it!</div>
<div style="margin: 0cm 0cm 0pt;">
<span class="pun"><span style="font-size: x-small;"><i><br /></i></span></span>
<span class="pun"><span style="font-size: x-small;"><i>$applicationName = "SQLPS ($env:USERNAME@$env:COMPUTERNAME)"<br />$SQLServerConnection = New-Object System.Data.SqlClient.SqlConnection<br />$SQLServerConnection.ConnectionString = "Data Source=$(ESCAPE_NONE(SRVR));Initial Catalog=master;Integrated Security=SSPI;Application Name=$applicationName"<br />$PolicyStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection($SQLServerConnection)<br />$PolicyStore = New-Object Microsoft.SqlServer.Management.Dmf.PolicyStore ($PolicyStoreConnection)<br />$PolicyStore.EraseSystemHealthPhantomRecords()</i></span></span></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike><br /></strike>
Just cut and paste that into Step 3 of the syspolicy_purge_history job, and the mysterious errors stop.Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com1tag:blogger.com,1999:blog-2139762005134795152.post-2574838159928996832018-08-10T06:04:00.000-07:002018-12-13T07:56:08.499-08:00How long does it take to create a database? <br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">How long does it take to create a database? </span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Well, depends on the piece of string on your pocket, of
course – how big is the database, how zippy your server is, and so on. </span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">But ideally, you want to create it ASAP. </span></div>
<span style="font-family: "calibri";"><br /></span>
<span style="font-family: "calibri";">Does the database ever need to grow? </span><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Well, if you have sized it perfectly, it will never need to
grow. <Howls of derisive laughter></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">OK, seriously, of course it does, and you want it to grow as
quickly as possible too. </span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">By default, before it creates or grows a file, SQL Server
pauses for a moment, maybe quite a few moments, to wipe out any existing data
by writing zeroes all over the space it needs.
Which is a sensible precaution if you want to make absolutely sure that
nobody can hack into your server and read stuff that you had previously
deleted. But if you are writing data
over it anyway, that might be a bit excessively paranoid. Or maybe you ARE excessively paranoid? Perhaps you have enough security in place
that you would like to consider trading that precaution for speed and
performance. Only you can decide
that. </span></div>
<div style="margin: 0cm 0cm 0pt;">
<br />
<br />
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="font-family: "calibri";"><br /></span></div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="font-family: "calibri";"><span style="background-color: transparent; color: black; display: inline; float: none; font-family: "calibri"; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Find a development server, and</span> check the file
location of an existing database, like this:</span></div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="background-attachment: scroll; background-color: white; background-image: none; background-repeat: repeat; background-size: auto; color: blue; font-family: "consolas"; font-size: 12.66px;">use</span><span style="background-attachment: scroll; background-color: white; background-image: none; background-repeat: repeat; background-size: auto; color: black; font-family: "consolas"; font-size: 12.66px;"> dbadmin</span></div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="background-attachment: scroll; background-color: white; background-image: none; background-repeat: repeat; background-size: auto; color: black; font-family: "consolas"; font-size: 12.66px;"></span><span style="background-attachment: scroll; background-color: white; background-image: none; background-repeat: repeat; background-size: auto; color: blue; font-family: "consolas"; font-size: 12.66px;">go</span></div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: transparent; color: black; font-family: Times New Roman; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span style="background-attachment: scroll; background-color: white; background-image: none; background-repeat: repeat; background-size: auto; color: maroon; font-family: "consolas"; font-size: 12.66px;">sp_helpfile</span></div>
</div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br /></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Now create a database. See how long it takes. </span><span style="font-family: "calibri";">In my Dev environment, this ran in 3 minutes, 17 seconds:</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">USE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> [master]</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">CREATE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">DATABASE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> [Fred] </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">PRIMARY</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'Fred_Data'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FILENAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'G:\data\Fred_Data.mdf'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> SIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 102596608KB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> MAXSIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">UNLIMITED</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> FILEGROWTH </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 0</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">LOG</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'Fred_Log'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FILENAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'H:\logs\Fred_Log.ldf'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> SIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 2621440KB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> MAXSIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 2048GB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> FILEGROWTH </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 0</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Okay, three minutes
for 100GB, not totally shabby. </span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Let’s try it without writing the zeroes. It's called Instant File Initialization, if you want to do any further reading - I like <a href="https://www.brentozar.com/blitz/instant-file-initialization/" target="_blank">Brent Ozar's write-up</a></span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">It isn’t a box to tick or a script to run, I’m afraid. </span><span style="font-family: "calibri";"> you need to restart the SQL Server service, so it will
have to be done out of hours on Production.</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">First thing you need is the name of your service account:</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">-- 2008r2 onwards</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> service_account</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">* </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sys</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">dm_server_services</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">For example - e.g. GANDALF\sqldev_frodo</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Open a Remote Desktop Connection to the server</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Run SECPOL.MSC (Local Security Policy)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Open up the Local Policies</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Click on User Rights Assignment</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Scroll right down to Perform Volume Maintenance Tasks</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Open it up and add the service account</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Click on OK</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Now you need to restart the SQL Server Service</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Run SERVICES.MSC</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Scroll down to the SQL Server services – there are probably
a few of them</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Stop the SQL Server Agent (MSSQLSERVER) service first</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Then stop SQL Server (MSSQLSERVER)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Then start SQL Server (MSSQLSERVER)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">And finally start SQL Server Agent (MSSQLSERVER)</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Why in that order? If
you stop SQL Server (MSSQLSERVER), the Agent service should stop automatically</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">If you restart SQL Server (MSSQLSERVER), it should stop,
stop the agent, and restart (though you have to remember to restart the agent).</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">So why bother with the extra steps?</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Because that is what SHOULD happen. Sometimes the restart thing gets stuck. This may be me remembering something that
used to happen and has now been fixed, senile old fool, stuck in his ways. So feel free to try restart. Just don’t come whingeing to me if it doesn’t
do what it should do. Because I shall
say I Told You So</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpPkEWs7YuRNo5jXu-6kmQHQNhVRFtVBnx2sIatO9kf5TQQlWw1rt0rZPVbCZlPjpgt1Mm9zYvgAEbTwzgNhKRgyu1PWFq-7QRUfaHuWTReL4_t_p0za-3_oHHB21oSzPGaw91c-ONUyKa/s1600/I+told+you+so.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="280" data-original-width="400" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpPkEWs7YuRNo5jXu-6kmQHQNhVRFtVBnx2sIatO9kf5TQQlWw1rt0rZPVbCZlPjpgt1Mm9zYvgAEbTwzgNhKRgyu1PWFq-7QRUfaHuWTReL4_t_p0za-3_oHHB21oSzPGaw91c-ONUyKa/s320/I+told+you+so.jpg" width="320" /></a></div>
<span style="font-family: "calibri";"><br /></span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Back to that script.
Remember the script to create the database?</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">USE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> [master]</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">DROP</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">DATABASE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> [Fred]</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"></span><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></span></div>
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">
</span>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">CREATE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">DATABASE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> [Fred] </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">PRIMARY</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></span></div>
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">
</span>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'Fred_Data'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FILENAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'G:\data\Fred_Data.mdf'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> SIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 102596608KB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> MAXSIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">UNLIMITED</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> FILEGROWTH </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 0</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span></span></div>
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">LOG</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'Fred_Log'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FILENAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">N'H:\logs\Fred_Log.ldf'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> SIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 2621440KB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> MAXSIZE </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 2048GB </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> FILEGROWTH </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> 0</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
</span><br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Before, this ran in 3 minutes, 17 seconds.</span></div>
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">Now? 18 seconds. </span></div>
<span style="font-family: "calibri";"><br /></span>
<span style="font-family: "calibri";">That’s a pretty good improvement</span><br />
<br />
<div style="margin: 0cm 0cm 0pt;">
<br /></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-22521731232071513302018-08-07T03:46:00.001-07:002018-12-11T02:09:26.999-08:00Tables with Spaces in the NameSomeone has created a table called Complaint Log<br />
Not ComplaintLog or even Complaint_Log<br />
<br />
I want to drop an index, so enclosing it in square brackets does the trick<br />
<br />
<div style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">DROP</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">INDEX</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">
[IX_Complaint_Log_SNP_Number] </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> [dbo]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">[Complaint Log]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">;</span></div>
And of course I could do it with the GUI, just by pointing and clicking, all that stuff<br />
<br />
But, I want to do it with a script and run it at 0300, and I want to check whether the index actually exists before my script tries to drop it. <br />
<br />
Normal thing would be to do something like this:<br />
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">IF</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">EXISTS(</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">*</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sys</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">indexes</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">WHERE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">object_id</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">object_id</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">(</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'dbo.Complaint Log'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">AND</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'IX_Complaint_Log_SNP_Number'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">)</span></div>
<br />
<div style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">DROP</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">INDEX</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">
[IX_Complaint_Log_SNP_Number] </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> [dbo]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">[Complaint Log]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">;</span></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike><br /></strike>
But because of that pesky space, it doesn't work. Oh, it says it does - it says<br />
Command(s) completed successfully.<br />
But it is lying - the index is not found, and it is not deleted<br />
<br />
It would be very satisfying to hunt down the guy who created Complaints Log instead of Complaints_Log, but in these namby pamby days of political correctness gone mad, torturing and killing Developers is frowned upon.<br />
<br />
<a href="https://www.linkedin.com/in/sspraakman/" target="_blank">Stefan Spraakman</a> gave me the answer - thanks Stefan! I need to join sys.indexes with sys.objects and test on the name, like this: <br />
<br />
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">IF</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">EXISTS(</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">*</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sys</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">indexes</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">AS</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> i </span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 3;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">INNER</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">JOIN</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sys</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">objects</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">AS</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> o </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> o</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">object_id</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> i</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: magenta; font-family: "consolas"; font-size: 9.5pt;">object_id</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 3;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">WHERE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> o</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">name</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'Complaint Log'</span></div>
<br />
<div style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"><span style="mso-tab-count: 3;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">AND</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> i</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">.</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">NAME</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">'IX_Complaint_Log_SNP_Number'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">)</span><br />
<span style="background-color: white; color: grey; font-family: "consolas";"><br />
<br />
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">DROP</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">INDEX</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">
[IX_Complaint_Log_SNP_Number] </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> [dbo]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">[Complaint Log]</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">;</span><br />
</span><br />
<br /></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-84586474081736381892018-07-13T08:55:00.000-07:002018-08-17T04:25:21.244-07:00Backup CompressionWho wants big backups? Not me, and probably not you<br />
<br />
You can compress your backups, starting from SQL Server 2008. <br />
<br />
In a maintenance plan, just select the option Compress<br />
<br />
In a script, add the magic words WITH COMPRESSION<br />
<br />
But you can set the default so that if you forget, it compresses for you. <br />
<br />
<a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/view-or-configure-the-backup-compression-default-server-configuration-option?view=sql-server-2017#TsqlProcedure" target="_blank">I'm indebted to Microsoft for this unusually clear description</a><br />
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">-- before - 0 means OFF</span></div>
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">value</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">configurations</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">name</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">'backup compression default'</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">GO</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">EXEC</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: maroon; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sp_configure</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">'backup compression default'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> 1 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span></div>
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">RECONFIGURE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">WITH</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">OVERRIDE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">GO</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><br />
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><br />
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">--after - 1 means ON</span></div>
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">value</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">configurations</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">name</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">'backup compression default'</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">GO</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><br />
<br />
<br />
You don't even have to restart anything!<br />
<br />
<br />
Is it worth doing? What do you mean, don't you trust me?<br />
I think so. Here's a way to calculate the actual compression achieved - on my server, out of 1,628 backups, I got a compression ratio of 3.02<br />
<br />
<br />
<div style="margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span></div>
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sum</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">backup_size</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> All_Backups</span><br />
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">,</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sum</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">compressed_backup_size</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> All_Compressed</span><br />
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">,</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sum</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">backup_size</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">)/</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">sum</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">compressed_backup_size</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Compression_Ratio</span><br />
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> msdb</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">..</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">backupset</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
<br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-64919920790195653682018-07-13T08:54:00.001-07:002018-07-13T08:59:26.650-07:00MadnessWhat maniac thought that the Approved field would be a good candidate for an index?<br />
<br />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 128px;">
<colgroup><col span="2" style="width: 48pt;" width="64"></col>
<tbody>
<tr height="19" style="height: 14.4pt;">
<td height="19" style="background-color: transparent; border: 0px black; height: 14.4pt; width: 48pt;" width="64"><span style="font-family: "calibri";">Approved</span></td>
<td style="background-color: transparent; border: 0px black; width: 48pt;" width="64"><span style="font-family: "calibri";"> HowMany</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" height="19" style="background-color: transparent; border: 0px black; height: 14.4pt;"><span style="font-family: "calibri";">0</span></td>
<td align="right" style="background-color: transparent; border: 0px black;"><span style="font-family: "calibri";">876528</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" height="19" style="background-color: transparent; border: 0px black; height: 14.4pt;"><span style="font-family: "calibri";">1</span></td>
<td align="right" style="background-color: transparent; border: 0px black;"><span style="font-family: "calibri";">446593</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" height="19" style="background-color: transparent; border: 0px black; height: 14.4pt;"><span style="font-family: "calibri";">-1</span></td>
<td align="right" style="background-color: transparent; border: 0px black;"><span style="font-family: "calibri";">24</span></td>
</tr>
</tbody></colgroup></table>
<div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike><br /></strike></div>
<div>
And what on earth can -1 signify?</div>
<div>
<br /></div>
<div>
And why did they use an INT as the data type?</div>
<div>
<br /></div>
<div>
Argh!</div>
<br />Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-64785577565877029922018-06-20T03:54:00.001-07:002020-10-15T08:44:42.417-07:00Database Mail – What could possibly go wrong?<br />
<div style="margin: 0cm 0cm 10pt;">
<span style="font-family: "calibri";">Fans of SQL Server will know that the answer is LOTS! </span><span style="font-family: "calibri";">So I shall try to make some kind of sense of it. I hope you find it helpful.</span></div>
<div style="margin: 0cm 0cm 10pt;">
<span style="font-family: "calibri";">If you are in a rush, skip to the end where I have listed three things to make sure </span></div>
<div style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">Start by sending a
test message to yourself</span></b></div>
<div style="margin: 0cm 0cm 10pt;">
<span style="font-family: "calibri";">Easiest way I think is to open Management in SSMS, right click
on database mail, and select Send Test E-Mail. Have a look in your inbox. </span><span style="font-family: "calibri";"><br /></span><span style="font-family: "calibri";">But if you want to do it with a bit of T-SQL, why not?</span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--send test message</span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">USE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> msdb</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">GO</span></div>
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"></span><br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">EXEC</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">sp_send_dbmail</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">@profile_name</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'H2SO4'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 4;"> </span></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">-- whatever the mail profile is called</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">@recipients</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'jack.whittaker@mycompany.co.uk'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">-- YOUR email, duh</span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">@subject</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'Test Message'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">@body</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'If
you can read this email, your database mail is working';</span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;"><br /></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">go</span></div>
<br />
<div style="margin: 0cm 0cm 10pt;">
<span style="font-family: "calibri";"><br />If you find that message in your inbox, well done, go and
have a nice cup of tea. </span></div>
<br />
<br />
<div style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">No sign of your
message?</span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";"><br /></span></b><span style="font-family: "calibri";">Check out your Junk / Deleted Items folders – I did a lot of
troubleshooting today, as emails were being
caught by a Junk rule and being automatically moved to my Junk folder. If you have set up rules to send automated
messages to a folder, check there too. </span></div>
<br />
<div style="margin: 0cm 0cm 10pt;">
<br /></div>
<div style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">Is it a permissions
issue? </span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";"><br /></span></b><span style="font-family: "calibri";">Add this little bit of code before the above script and try
again. </span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">EXECUTE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">AS</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">LOGIN</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'SA'</span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<br /></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<br />
<div style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">Check the Logs</span></b></div>
<span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";"></span></span><div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";"><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">USE MSDB<br />GO<br /><br /></span></span></span></div><div style="line-height: normal; margin: 0cm 0cm 0pt;"><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";"><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span></span></span></div>
<span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"> <span style="color: black;">sa</span></span><span style="background: white; font-family: "consolas"; font-size: 9.5pt;"><span style="color: black;">i</span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sent_status</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sai</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">subject</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sai</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">body</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sai</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">last_mod_date</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sai</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">recipients</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sel</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">description</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">as</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> Log_Message</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sysmail_allitems</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">as</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sai</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">INNER</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">JOIN</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sysmail_event_log</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">AS</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sel</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">ON</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sai</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">mailitem_id </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sel</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">mailitem_id;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span>If all are UNSENT, think about restarting the SQL
server agent service</div>
</span><div style="line-height: normal; margin: 0cm 0cm 0pt;">
</div>
</span><br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
</div>
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<br /></div>
<br />
<br />
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "calibri";">The Event Log may or may not be helpful. I</span><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">t usually tells you</span></span><span style="font-family: "calibri";"> either </span></div>
<br />
<div style="line-height: normal; margin-bottom: 0cm; margin-left: 54.0pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54pt; mso-add-space: auto; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; text-autospace: none; text-indent: -36pt;">
<span style="background: white; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-highlight: white;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";">1)</span><span style="font: 7pt "Times New Roman";">
</span></span></span><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">DatabaseMail process is started</span></span></div>
<div style="line-height: normal; margin-bottom: 0cm; margin-left: 54.0pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54pt; mso-add-space: auto; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; text-autospace: none; text-indent: -36pt;">
<span style="background: white; mso-highlight: white;"></span><span style="background: white; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-highlight: white;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";">2)</span><span style="font: 7pt "Times New Roman";">
</span></span></span><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">DatabaseMail process is shutting down</span></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<br />
You can ignore these by adding a where clause, but the started and shutting down messages indicate that it is working normally.<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">use</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> msdb</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">go</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">select</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">*</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">from</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sysmail_event_log</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--where event_type != 'information'</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">order</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">by</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> log_id </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">desc;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"></span><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";"><br /></span></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">There are a couple of other things you can look at,
but probably not helpful if you have already looked at sysmail_allitems</span></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">-- list all emails</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sent_status</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">
</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">*</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">sysmail_mailitems;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--List all SENT emails</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> sent_status</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">,</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">
</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">*</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;">sysmail_sentitems;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt; line-height: 115%;"></span><span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";"><br /></span></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"><span style="font-family: "calibri";">And one of these things might give you a clue</span></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; mso-highlight: white;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--Should be 1 ie Yes</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">SELECT</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> is_broker_enabled </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">FROM</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">sys</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: lime; font-family: "consolas"; font-size: 9.5pt;">databases</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">WHERE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">name</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'msdb'</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--should be started</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">EXECUTE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> msdb</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;">dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">sysmail_help_status_sp;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--state should be active</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">sysmail_help_queue_sp</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> @queue_type </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">=</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: "consolas"; font-size: 9.5pt;">'Mail'</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;">--ensure that sysmail has been
started</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: green; font-family: "consolas"; font-size: 9.5pt;"></span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: "consolas"; font-size: 9.5pt;">EXECUTE</span><span style="background: white; color: black; font-family: "consolas"; font-size: 9.5pt;"> dbo</span><span style="background: white; color: grey; font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;">sysmail_start_sp;</span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="background: white; color: maroon; font-family: "consolas"; font-size: 9.5pt;"></span><b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";"><br /></span></b></div>
<div style="line-height: normal; margin: 0cm 0cm 0pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">Things to make sure </span></b></div>
<br />
<div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";">A)</span><span style="font: 7pt "Times New Roman";">
</span></span></span><span style="font-family: "calibri";">Database Mail insists that you have .NET
Framework 3.5 on your server. You might
notice that you have .NET Framework 4.5, so you don’t need the old version,
right? </span><span style="font-family: "calibri";">WRONG</span><span style="font-family: "calibri";"> <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/dn482071(v=win.10)" target="_blank">Check out how to do it here</a></span><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";"></span></span></span></div>
<div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";"><br /></span></span></span></div>
<div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";">B)</span><span style="font: 7pt "Times New Roman";">
</span></span></span><span style="font-family: "calibri";">If you can send an email from the Database Mail,
but not from SQL Agent jobs, you may have forgotten to enable a mail profile
for alerts.</span></div>
<ol>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";">Right click on "SQL Server Agent"</span></div>
</li>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";">Then "Properties".</span></div>
</li>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";">Then go to "Alert System" section.</span></div>
</li>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";">Tick the "Enable mail profile" box.</span></div>
</li>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";">Then "OK".</span><b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";"> </span></b></div>
</li>
<li><div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "calibri";">MUST do - Restart the SQL Server Agent service</span></b><span style="font-family: "calibri";">.</span><span style="font-family: "calibri";"> </span><span style="font-family: "calibri";"><br /></span></div>
</li>
</ol>
<div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="font-family: "calibri";"><br /></span></div>
<div style="margin: 0cm 0cm 10pt 36pt; text-indent: -18pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font-family: "calibri";">C)</span><span style="font: 7pt "Times New Roman";">
</span></span></span><span style="font-family: "calibri";">And if Database Mail seems to be sending, but
you are not receiving, check again that your message is not being caught by a
filter. Sysadmins will be able to look
for the message in Exchange. You can check
it by sending a test message to a colleague.</span></div>
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-80327482350450573122018-03-19T06:06:00.000-07:002018-08-10T07:42:44.008-07:00Heartbeat<div dir="ltr">
SQL server Agent runs jobs, and if they fail to run, it can be configured to send you a message to say they have fallen over. You can if you like configure it to send a message if it succeeds too. Beware! That way lies madness. </div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
Problem with a Job Succeeded message is that there may be dozens, even hundreds of servers. Each server might easily have dozens, even hundreds of jobs running on them. Once a day, once an hour, once a minute even. So for 50 servers running 25 jobs every hour on the hour, that is a lot of emails. You will probably delete them automatically without reading them, and so miss the one you really care about - the one job that failed last night. </div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
So set it up to notify you of jobs that fail. </div>
<div dir="ltr">
<br />
All well and good. But how will you know if SQL Server Agent itself has failed? It does, occasionally. </div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
I set up a job on each server which runs a Job Succeeded job on each server, once a day. At midnight, before the more significant jobs run. It sends me a message. I never read it. </div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
But I have set up rules in my email which put the messages into folders, one per server. The job almost always succeeds, and every day, the number of messages goes up by one. </div>
<div dir="ltr">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgt52Zj41UwntP3KPKhuF6kr45l9m-pknNrnxl7MYLtRUjz6aCkjW2Fhhx7Uie2JQqDdgvddh6iQwbea4cZLFBQPyGtFax-vDT9CIs7hkQUYRcHJEQ1pjAFjoIvmUgnhSLo0rRPdirzB2S/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="181" data-original-width="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgt52Zj41UwntP3KPKhuF6kr45l9m-pknNrnxl7MYLtRUjz6aCkjW2Fhhx7Uie2JQqDdgvddh6iQwbea4cZLFBQPyGtFax-vDT9CIs7hkQUYRcHJEQ1pjAFjoIvmUgnhSLo0rRPdirzB2S/s1600/Capture.PNG" /></a></div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
But if SQL Server Agent ever fails on any server, the number of messages will be different. I can see at a glance that something has gone wrong</div>
<div dir="ltr">
<br /></div>
<div dir="ltr">
And I can go and fix <u>it</u></div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-72037945166499856212018-03-09T23:57:00.001-08:002018-03-09T23:57:53.057-08:00SSRS access denied<p dir="ltr">Nobody can run the SSRS reports I laboriously created, which rather makes life pointless. Yet they have permissions to do so. At the highest level. I upgrade a user to Content Manager. Nope. As soon as he tries to run it, it fails. </p>
<p dir="ltr">I'm indebted to Sajid Pandore for the solution</p>
<p dir="ltr">To see where it was denying the access, he ran this QUERY on the RS1 server</p>
<p dir="ltr">Use ReportServer<br>
Go</p>
<p dir="ltr">select *<br>
from ExecutionLog3 <br>
order by TimeStart desc;</p>
<p dir="ltr">It seemed that the query was being denied permission to run one specific dataset, dtsAcYear, which contains data for the Academic Year parameter. Unfortunately, this is the first parameter the system gets to. </p>
<p dir="ltr">Checked the permission on that Dataset – we found that the BI User group for some strange reason was not listed there.</p>
<p dir="ltr">I am not sure why it did not inherit the permissions from the higher level. All the other datasets did!</p>
<p dir="ltr">We added this manually and tested the report all seems to be working now. </p>
<p dir="ltr">Until the next thing goes wrong </p>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-54951888657802744742018-03-09T23:45:00.001-08:002018-10-18T08:28:17.191-07:00SSIS Job Failure @P21 error<div dir="ltr">
My SSIS job fails with an @P21 error message</div>
<div dir="ltr">
Huh? There is no such parameter in my stored procedure. There are quite a few, but not 21 of the dratted things. </div>
<div dir="ltr">
The job was trying to run a stored procedure to updated changed records. The procedure ran perfectly well in SQL server. But not when I built it into an SSIS job. </div>
<div dir="ltr">
Here's why. Muggins here typed:<br />
exec usp_update ?.?.?.?.?</div>
<div dir="ltr">
And I should have written:<br />
exec usp_update ?,?,?,?,? </div>
<div dir="ltr">
D'oh!</div>
<div dir="ltr">
</div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-45703512350100336302017-07-04T11:11:00.000-07:002017-07-04T11:14:14.613-07:00Sometimes Database Administration Isn't Challenging Enough<br />
<div style="background: white; margin: 0px;">
<br />
<div style="background: white; margin: 0px;">
<span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 18pt; margin: 0px;">First,
we wrap the "hole guy's" arm in a skin for protection</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span></div>
<br />
<div style="background: white; margin: 0px;">
<span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/2ATT00001.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/2ATT00001.jpg" height="364" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1033" style="min-height: 3.791in; width: 6.386in;" unselectable="on" width="613" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Then we find a big hole and the "hole guy" crawls in.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/1ATT00002.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/1ATT00002.jpg" height="855" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1032" style="min-height: 8.91in; width: 6.404in;" unselectable="on" width="615" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">We use modern lighting...</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/3ATT00003.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/3ATT00003.jpg" height="429" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1031" style="min-height: 4.47in; width: 6.446in;" unselectable="on" width="619" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">There it is.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/8ATT00004.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/8ATT00004.jpg" height="421" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1030" style="min-height: 4.386in; width: 6.428in;" unselectable="on" width="617" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Those must be eggs.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/7ATT00005.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/7ATT00005.jpg" height="474" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1029" style="min-height: 4.94in; width: 6.416in;" unselectable="on" width="616" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">I let it take my protected arm, sort of like noodling for fish.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/5ATT00006.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/5ATT00006.jpg" height="847" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1028" style="min-height: 8.821in; width: 6.404in;" unselectable="on" width="615" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Then my buddy pulls me out with the snake attached.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/9ATT00007.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/9ATT00007.jpg" height="864" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1027" style="min-height: 9in; width: 3.702in;" unselectable="on" width="355" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Ain't it a beauty?</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 95pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/4ATT00008.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/4ATT00008.jpg" height="864" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1026" style="min-height: 9in; width: 5.72in;" unselectable="on" width="549" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">It will feed the whole village for a while.</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
<img alt="http://static.tinyletter.com/AZJunk/img/beam/3343997/6ATT00009.jpg" src="http://static.tinyletter.com/AZJunk/img/beam/3343997/6ATT00009.jpg" height="720" id="ydpef1d0786yiv5456871083m_3335685870961862174m_-7993256753044244179m_3285144983428818460aolmail_m_7070848417352640231yiv3589364675_x005f_x0000_i1025" style="min-height: 7.5in; width: 6.452in;" unselectable="on" width="619" /><br />
<br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Snake Noodling - - - - - What real men do!</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span><span style="color: #26282a; font-family: "helvetica" , sans-serif; margin: 0px;"><br />
</span><span style="color: #505050; font-family: "helvetica" , sans-serif; font-size: 24pt; margin: 0px;">Maybe standing in line at the grocery store isn't as bad as it
seems!!!</span><span style="color: #26282a; font-family: "helvetica" , sans-serif; font-size: 9.5pt; margin: 0px;"> </span></div>
<br />
<div style="background: white; margin: 0px;">
<br /></div>
<br />
<div style="background: white; margin: 0px;">
<br /></div>
<br />
<div style="background: white; margin: 0px;">
<br /></div>
<br />
<div style="background: white; margin: 0px 0px 16px;">
<br /></div>
</div>
<div style="background: white; margin: 0px;">
<br /></div>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-4429038566850608872015-10-06T11:54:00.001-07:002015-10-06T11:55:00.095-07:00The Pointless Job<p dir="ltr">The job failed. It had been working forever and suddenly it wasn't any more. There was of course no documentation - well you knew that. There was no description in the job description. It ran an obscurely named stored procedure. </p>
<p dir="ltr">Okay, the SP connected to an entirely different server, extracted some data from a database that didn't exist, and sent it to an unknown FTP server. Well, extracting something from a database that doesn't exist (having been dropped yesterday) probably explains why the job was failing today. </p>
<p dir="ltr">The database in question was for a client we stopped working with about five years ago. And looking at the history it seemed likely that we had been extracting nothing for those five years, encrypting the nothing, and sending it to the client that we no longer worked with. Somewhere in the former client's IT department there must be a bod wondering about his error message... </p>
<p dir="ltr">Asking around, one of the developers remembers the customer wanting us to encrypt an empty file and ftp it to them, even though the customer had no business for us. Something about keeping a gateway open just in case...</p>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com0tag:blogger.com,1999:blog-2139762005134795152.post-71606462268406324372015-09-26T03:31:00.001-07:002015-09-26T03:31:46.124-07:00Those Pesky Recruitment Consultants<p dir="ltr">Let me tell you about Vic* - he is a recruitment consultant, of course, in other words a salesman. I used to be a salesman, so I know a bit about what goes on. This all happened a couple of years ago, but I doubt if Vic has changed much. </p>
<p dir="ltr">Vic had a chat with me, got my CV, and put me forward for a job. But he didn't actually get round to telling me that he was putting me forward, nor did he send me a job spec, nor did he tell me who the client was, which is a bit naughty. But, you know - sometimes you have to be a bit proactive in this life, and enthusiasm counts for a lot.</p>
<p dir="ltr">Which was fine until Bob* called. Bob had a chat, got my CV, told me about his client, sent me the job spec, gave me the client's name, and I agreed that Bob should put me forward. </p>
<p dir="ltr">You see where I'm going, don't you? The client wisely didn't want to get involved with a nest of vipers. </p>
<p dir="ltr">Then Vic had another go, on a new job a few months later. He told me about the client - Joseph Bloggs International*, got my CV, told me he was putting me forward. Lessons learnt - well done Vic!</p>
<p dir="ltr">Two or three other agencies contacted me about Bloggs -I told them I had already been put forward, and they shrugged their shoulders and moved on.</p>
<p dir="ltr">Then - nothing. No interview, no feedback. Nothing. I shrugged my shoulders and moved on. </p>
<p dir="ltr">Until I met Susan* - she was interviewing me for another job. Susan was the outgoing DBA, and she was leaving to go to a firm called Joseph Bloggs International. Nice step up for her, really interesting job. Yes indeed. Except looking at her profile she actually wasn't so well qualified as me. And although I'm sure she will be great at Bloggs, they really should have interviewed both of us before choosing her. </p>
<p dir="ltr">Vic had done it again. He got his hooks into me, but didn't land the contract with the client, so didn't actually put me forward. Hence no feedback. </p>
<p dir="ltr">So advice please - as a mere candidate, what am I supposed to do when an agency rings me? If you work in recruitment please tell me the secret formula that renders consultants powerless to tell me big fibs.<br><br></p>
<p dir="ltr">*Names changed to protect the guilty</p>
<p dir="ltr"> </p>
Jackhttp://www.blogger.com/profile/05090709421951064507noreply@blogger.com1