mrfoxsql-gravatar-full.jpg

A Collection of SQL Server Help Scripts

,

[read this post on Mr. Fox SQL blog]

Like probably every SQL DBA, consultant, architect etc etc out there that has ever worked on or used SQL Server they will likely have their own personal collection of SQL Server Help Scripts.

So not unsurprisingly I also have such a collectionand so this is the purpose of this post!

The below is a link to my GitHub repo of my personal collection of scripts.  BTW this isn’t all of the scripts, but is probably 50% of the ones I have lurking around.

These are either scripts I have developed in my own time over the years, or adapted from various other websites which I found handy at the time for whatever reason.

Where I have remembered that web site (like most people, which is unfortunately almost never) it was typically from sites like stack overflow etc, and if so I have tried to cite it as such to provide credits.

 

Quite a few of my scripts are in fact scripts that generate other scripts!

So in other words – its a script you run on a source SQL Server where the output of that script execution is in fact another script that performs some dynamic operation based on the source server configuration at the time the original script was run.

These are perfect for those times you need to create scripts for some later activity, such as to say backup or restore databases, recreate indexes, change database properties, set login properties, etc etc

 

The below is the link to the repo and a list of the scripts I have there.  Read on!

Code Caveats

Oh, but before we do that… I’m spelling out my usual caveats… sorry…

THESE SCRIPTS/CODE ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED.  LIMITED TESTING HAS BEEN PERFORMED ON THESE SCRIPTS/CODE AND THEREFORE THE AUTHOR DOES NOT WARRANT THAT ANY SCRIPT/CODE IS BUG OR ERROR-FREE.  IT IS EXPECTED THAT ANY SCRIPT/CODE UNDERGO YOUR OWN TESTING AND/OR VALIDATION BEFORE USAGE ON ANY CRITICAL SQL SERVER PLATFORM.  THESE SCRIPTS MAY BE A COLLECTION OF MY OWN CODE COLLATED OVER MANY YEARS, OR OTHER CODE I HAVE LOCATED ON THE WEB OFTEN WITH AN UNKNOWN ORIGIN. WHERE CODE LINAGE HAS BEEN SPECIFICALLY IDENTIFIED IT WILL BE CITED AS SUCH BACK TO THE ORIGINAL AUTHOR OF THAT CODE.

 

GitHib Repo – Collection of Downloadable Scripts

https://github.com/rolftesmer/SQLServerHelpScripts

 

List of SQL Script Files

I have tried to keep the names of the script files in a self-describing way so that you can tell what they do.  Each file also has a header that explains a little about what it does.

 

KillDBConnections.sql

ListDBFileGrowthHistoryFromDefaultTrace.sql

ListDBFileSettingsAndGrowth(2012+).sql

ListDBHowMuchDataHasChangedSinceFullBackup.sql

ListDBNotAccessed.sql

ListDBOnSameDriveLetter.sql

ListIndexFrag.sql

ListIndexesAll.sql

ListIndexesNotUsed.sql

ListIndexesUsed.sql

ListLastDBBackups.sql

ListLastDBRestores.sql

ListLastTimeTableStatsUpdated.sql

ListSSRSReportsSchedules.sql

ListSSRSReportsSchedulesAndHistory.sql

ListTableCompressionSettings.sql

ListTablePartitionCalculationFromColoumn.sql

ListTablePartitionSettings.sql

ListTablesLastAccessed.sql

ListTablesNotAccessed.sql

ListTablesWithNoPrimaryKey.sql

SQLGen_AttachDatabases.sql

SQLGen_AutoShrinkClose.sql

SQLGen_Backup.sql

SQLGen_ChangeDBOwner.sql

SQLGen_DBCC_CHECKDB.sql

SQLGen_DBCompatLevel.sql

SQLGen_DBIndexPhysicalStats.sql

SQLGen_DBRecoveryMode.sql

SQLGen_DetachDatabases.sql

SQLGen_DropAllIndexes.sql

SQLGen_ExtractAllDatabaseIndexScripts.sql

SQLGen_ForeignKeys.sql

SQLGen_MergeStatement.sql

SQLGen_Offline.sql

SQLGen_PartitionStatment.sql

SQLGen_ReindexAllIndexes.sql

SQLGen_ReindexFullText.sql

SQLGen_RenameObjects.sql

SQLGen_RestoreDBFromBackupFile.sql

SQLGen_SQLAgentJobsDisableEnable.sql

SQLGen_SetDefaultSchema.sql

SQLGen_SeverityAlerts.sql

SQLGen_Shrink_File.sql

SQLGen_SysMessages.sql

SQLGen_TPD.sql

SQLGen_TableAndIndexCompression.sql

SQLGen_TableIndexCompression.sql

SQLGen_UpdateStatistics.sql

AND of course, as I always say, please test this yourself as your results may vary!


Disclaimer: all content on Mr. Fox SQL blog is subject to the disclaimer found here

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating