Tag: administration

  • Cleaning Up Your Database

    How many of you have objects in your database that aren’t being used? What about something in a schema with a _old in the name? Or _2 or _3 or _delete? There is a lot of old, deprecated stuff I see in production databases. In fact, I’ve been somewhat amazed as I work with clients that many of the scripts we can build from a database with SQL Compare won’t actually execute on an empty database because the script is full of broken code.

    I also find plenty of DBAs that want to clean things up, but they don’t. Sometimes they’re afraid they’ll break something, which is certainly possible. Sometimes they can never find the time. Often they might ask a manager, who usually says this isn’t important and don’t bother.

    Is it worth it to clean up your databases?

    Brent says no for old code. I say maybe for tables and code.

    For a lot of code, Brent is right, your boss doesn’t care and it doesn’t necessarily help you. After all, it’s in production now, and if it’s being used, you’re going to just create problems with a DROP. Where is the business value for removing old code (assuming it isn’t being used)? What benefits do your clients get? Not you being happier there are less objects, but what is the business benefit.

    That’s the key. Is there a business benefit.  What I’d say is that if you have broken code, it needs to be removed. Because this does impact your software development process, especially when trying to match lower environments. For broken stuff, save the code in your VCS (you do version control database code, right?) and then delete this stuff from prod. It’s broken.

    Or fix it.

    For tables, I would want to get rid of old tables as well. Why? Well, this is real costs in storage and potential reading of old data. If we moved data to table_old and someone decided they needed to read this for a report at the time, they might still be reading old data. I’d first rename these objects as object_delete_date with the date being a month away. Then I’d set a reminder for that date. On that date, bcp out the data, then drop the table. Period.

    Two other things. First, make sure you know how to recreate the table (see the VCS comment above) and bcp in the data. Two, this is low-priority work. If you want to clean the database, know this is a long term, baby step process that will take months or years, and may never end.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

    Note, podcasts are only available for a limited time online.

  • Monday Monitor Tip: Compliance Checking for Old Versions

    A customer recently wanted to know if any of their instances were too old and out of support. This was for a compliance purpose, and they had the need to show a report to management of when instances were out of compliance with policies.

    This post shows how you can do this in Redgate Monitor.

    This is part of a series of posts on Redgate Monitor. Click to see the other posts

    Compliance Templates

    This is an Enterprise feature, but it allows the administrators of Redgate Monitor to define templates for how the various servers and databases ought to be configured. Deviance from standards, or compliance with standards is often something auditors care about you documenting.

    This is very easy with Redgate Monitor. Let’s see how this works.

    Under the Security tab (appears in Enterprise edition), you can see there is a Configuration Compliance item. Click this.

    2024-08_0127

    This brings up the Configuration Compliance screen. This starts with Servers (highlighted with a bar to denote this tab, but there are also databases and Compliance templates. We want to choose compliance templates.

    2024-08_0126

    This tab shows the various templates that exist already in the system. I’m looking at monitor.red-gate.com, which has three templates configured already.

    2024-08_0128

    If you scroll to the right, we can see that two of these are server (instance) templates and one is a database template. We can add a new one, or edit existing ones. For this post, I’ll edit the Workload Server template.

    2024-08_0129

    After we click Edit, we get another set of tabs for the template itself. The default is for security, but there are also performance and environment options. Pic the Environment tab.

    2024-08_0130

    This brings up a list of settings. Scroll down to the bottom and you will see what settings below for Product Level, Product Version, Product version number, and Edition.

    2024-08_0125

    In this case, the template is checking that every server has at least SQL Server 2019 Enterprise installed. If any other version were installed, this would show as non compliant. This is useful for grouping your servers by versions.

    The values entered here are the ones you would get back from the ServerProperty() function.

    Summary

    This post shows how you can configure a compliance template to check that the versions of SQL Server you have installed meet your requirements for a version.

    Redgate Monitor is a world class monitoring solution for your database estate. Download a trial today and see how it can help you manage your estate more efficiently.

  • Monday Monitor Tips–Finding CUs for My Instance

    How can I quickly get a CU patch for a system that’s out of date? I’ll discuss that situation.

    You might think you get to patch every instance every few months, and you may be able to. But most of us have laggards in any decent-sized estate. Someone always wants to avoid patching, or skip patching on the day you’ve scheduled every other system.

    This is part of a series of posts on Redgate Monitor. Click to see the other posts

    Tracking Versions

    The Estate page in Redgate Monitor contains quite a few different views of your entire estate. This section is designed to aggregate data across all the systems you are monitoring. If I look at https://monitor.red-gate.com/Estate/Versions, I see this as a default.

    2024-08_0041

    This gives me an overview of what SQL Server versions I’m monitoring. As you can see, our test estate has a mix of versions, from 2008R2 through 2022 and one Managed Instance. The counts are in the pie chart, and we can see how many are up to date in the bars to the right of each version. As you can see, lots of our estate needs patching.

    I can also see at a glance for each version that the latest update is and its release date. The download link is a quick way to download the latest patch from Microsoft. We maintain this list and Redgate Monitor will update it on a regular basis.

    When I scroll down, I see the details of individual instances. These are grouped, though I can change that with the toggle in the upper left. For each instance, I have the name and the major version,

    2024-08_0042

    The current status and the latest patch are listed next to each other, with an icon and color coding that let’s me know I need to upgrade (yellow up arrow) or I’m patched (green checkmark). I once again have the latest patch, linked to the MS article as well as text that let’s me know how out of date I am.  You can see these patches are a month old. Auditors are potentially OK with that.

    2024-08_0043

    However, for my 2012 instances, I’m way out of date. No excuse for that. We keep these firewalled and protected, and they are available here only for demonstration purposes.

    2024-08_0045

    To the right of this we have our support dates. If a date is past, we mark it with a triangle to let you know that you have unsupported versions. That may or may not be an issue for your organization.

    2024-08_0044

    Summary

    This section of the Estate tab isn’t something I expect DBAs or sysadmins to check often, but I would schedule a reminder to do this quarterly. Knowing the state of our patching process is important, especially when there are security updates being released. We have had a few in the last year for SQL Server, and it is important to patch and apply those.

    Seeing not only the status, but having an easy download link makes this a very handy tab that I wish I’d have had in quite a few jobs during the 90s and early 2000s. If you haven’t checked your estate tab in Redgate Monitor, you might do that today.

    Redgate Monitor is a world class monitoring solution for your database estate. Download a trial today and see how it can help you manage your estate more efficiently.

  • Saving Emergency Space on my Laptop

    With my new laptop, one of the things I realized I’d forgotten to do in setup is reserve some space. I wrote about this years ago, but I wanted to ensure I always had space in the event of an emergency.

    Creating Placeholders

    In the previous post, I linked to the contig utility from Microsoft. I downloaded this and then copied the new 64-bit utility to my c:\utilities folder, which is where I keep a lot of generic stuff I run.

    Then I copied my old command and updated the exe call.

    However, I also built a quick batch file to give me 20GB of saved space. I called it create20gb.cmd and it contains this code:

    contig64 -n Hold1.place 1073741824
    contig64 -n Hold2.place 1073741824
    contig64 -n Hold3.place 1073741824
    contig64 -n Hold4.place 1073741824
    contig64 -n Hold5.place 1073741824
    contig64 -n Hold6.place 1073741824
    contig64 -n Hold7.place 1073741824
    contig64 -n Hold8.place 1073741824
    contig64 -n Hold9.place 1073741824
    contig64 -n Hold10.place 1073741824
    contig64 -n Hold11.place 1073741824
    contig64 -n Hold12.place 1073741824
    contig64 -n Hold13.place 1073741824
    contig64 -n Hold14.place 1073741824
    contig64 -n Hold15.place 1073741824
    contig64 -n Hold16.place 1073741824
    contig64 -n Hold17.place 1073741824
    contig64 -n Hold18.place 1073741824
    contig64 -n Hold19.place 1073741824
    contig64 -n Hold20.place 1073741824

    I made a c:\hold folder and dropped the cmd file in there. I then ran it. Here are the results:

    2024-08_0053

    Now if I find myself running low on space, I can go in here and delete a few files and get some space back.

    I recommend this for all machines, since I’ve run into the space problem so often, usually at a time when I’m stressed and I need space quickly. This makes it easy to get a bit of space back.