r/SQLServer • • Jan 02 '19

SQL Server DBA Scripts

Hey All,

I've worked for different companies with different groups of DBAs over the past 10 years and each have had their own set of scripts and methods of troubleshooting, health checking, maintenance etc..

I'd like to standardize these scripts at my current company so I wanted to see if there is a 'Best Practice' set of scripts out there that you would recommend?

Thanks

LAPORTS

41 Upvotes

26 comments sorted by

29

u/slimrichard Jan 02 '19

I build everything around dbatools.

https://dbatools.io/commands/

2

u/LAPORTS Jan 02 '19

I've been to a couple of sessions with Rob Sewell and Chrissy Lemaire, dbatools is really powerful but we're not using it extensively yet.

We're looking use it to automate patching : https://nvarscar.wordpress.com/2018/12/30/automating-sql-server-patching/

13

u/BelleVieLime Jan 02 '19 edited Jan 03 '19

Best stuff.

Plus Ola for maint.

13

u/Solonas Jan 02 '19

I keep a copy of the most current version of Glenn Berry's scripts in my library. https://www.sqlskills.com/blogs/glenn/category/dmv-queries/

1

u/LAPORTS Jan 02 '19

Thank you! This is new to me, I'll get a look through today!

4

u/alinroc 4 Jan 02 '19

You can run these through dbatools. Invoke-DbaDiagnosticQuery

10

u/unholey1 Jan 02 '19

Ola hallengrens scripts are probably the most commonly used for all backup and database maintenance tasks. Just about every DBA I've spoken to either uses them or wants to.

I'd also give another vote for dbatools.io to give you more flexibility in creating your own scripts

1

u/LAPORTS Jan 02 '19

I always thought Microsoft should just work with Hallengren and packages these up. Great set of maintenance scripts

4

u/chandleya Jan 02 '19

From personal experience, they do work closely with him. I think for packaging sake they’re trying to bundle less management as the community has spoken up on that. Bundling it also stifles major change/improvement as they have to commit to keeping feature parity in a release.

2

u/sqldiaries Jan 02 '19

Ola hallengrens scripts are probably the most commonly used for all backup

Has anyone successfully use Ola's backup scripts with DDBoost? That's what we use for backups, but it doesn't use the SQL Server Native backup system - instead it leverages a virtual backup device generated by EMC for Data Domain.

0

u/[deleted] Jan 02 '19

[deleted]

2

u/SaveTheEmpire Jan 02 '19

False.

BackupSoftware Specify third-party backup software; otherwise, SQL Server native backup is performed.

  • Value Description

  • NULL SQL Server native backup (the default)

  • DATA_DOMAIN_BOOST DELL EMC Data Domain Boost

  • LITESPEED Quest LiteSpeed for SQL Server

  • SQLBACKUP Red Gate SQL Backup Pro

  • SQLSAFE Idera SQL Safe Backup

Edit: formatting

1

u/sqldiaries Jan 02 '19

Ola's backup script is all native backups, it doesn't target third-party backup tools.

That's what I thought. Oh well.

8

u/Boulavogue Jan 02 '19

I use many of http://andreas-wolter.com/en/blog/ scripts for tuning and security. Now that he has taken a role in MS I'm not sure how many more blogs will be posted. But for tuning and security they've been useful.

I can't see a public repo of Andreas's scripts but at a class last year he shared some. I'll look tomorrow for the unaltered scripts. Many I've tweeked for the company I'm working with

1

u/LAPORTS Jan 02 '19

That's fantastic - thank you!!!

5

u/astraljack Jan 02 '19

For maintenance, I'm a big fan of the free Minionware suite. Jen and Sean McCown of Midnight DBA put it together and it's top-notch. Coming from Ola's scripts, it's like living in the fucking future.

Toubleshooting/Health Checking - Brent Ozar sp_blitz all the way.

1

u/LAPORTS Jan 03 '19

This is a new one to me too. I'll check this out today - Thank you!

5

u/luisaoki Jan 03 '19

Adam Machanic's sp_whoisactive is another must have.

http://whoisactive.com/

1

u/LAPORTS Jan 03 '19

Definitely thumbs up for me on this one. Used daily!

1

u/haventohell Jan 03 '19

Anyone use something like an sql query library management system?

1

u/LAPORTS Jan 03 '19

Do you mean like a central location for scripts? I was planning on using Github for ours.

2

u/haventohell Jan 04 '19

There was a website running around a few years ago that allowed you to execute scripts from it, stored them all nicely, cool parameters.

a git repository works.

1

u/37Point8Percent Apr 20 '24

yes. they now call it CHAT-GPT.
you can also use Perplexity.ai
they keep ALL libraries for you.

1

u/37Point8Percent Apr 20 '24

in one place :) !

2

u/Chris_PDX Jan 02 '19

Glenn Berry + Brent Ozar and then add on as needed from there. My toolkit starts with scripts from those two.

0

u/[deleted] Jan 02 '19

[deleted]

1

u/LAPORTS Jan 02 '19

Good call. Brent Ozar's stuff is great.