Welcome to Cooking SQL
This website is a personal project to store most of the SQL scripts that I have either found on the web, created myself or even stolen (kidding… credit where credit is due).
Why CookingSQL? Well… I wanted a place to put some cool SQL scripts, and since pictures of scripts aren't pretty or fun… I'll be posting pictures of what I like to cook. I'm not a professional chef nor am I an MVP, I'm just an average Joe wanted a place to put my stuff.
All the post are categorized, and below is a quick way to find out what I have. Feel free to comment, add/amend or even kuddos. It'll be appreciated.
Table Of Content:
PowerShell Scripts
- Add Active Directory Domain Services
- All About Running commands Remotely
- All the basics for running Scripts in Powershell
- Delete files based on Age
- Find Out Who installed SQL
- Find Out Who Patched SQL
- Finding Location of ErrorLog
- Searching the Event Viewer
All the Basics
Backup Scripts
- Backup – Total Size Full Backups
- Backup Report
- Backup Report – All Servers
- Find If Mix Backup Types are Present
- Generate script to backup all databases
- Historical Backup Report
- How long backups will take
- Location of all last X backups – all DBs
- Location of last X backups – Single DB
- Location of very last Backups
- Location of very last Backups — All Databases
- Querying CommandLog
Restore Scripts
- Check When The Last Restore Was Performed
- How long backups will take
- Location of all last X backups – all DBs
- Location of last X backups – Single DB
- Location of very last Backups
- Location of very last Backups — All Databases
- Restore Full Backup and Tlog Generator
- Restore Generator for all BAK files in one folder
- Restore Script Generator one DB
- Resynchronize Orphaned Users
Index Fragmentation Scripts
- Check Fragmentation Levels
- Querying CommandLog
- Rebuild – Reorganize All Indexes
- Statistics last Updated
Performance Scripts
- Check Fragmentation Levels
- CPU Usage
- How long backups will take
- IO Usage by data file
- Last Autogrowth Event
- Location of Data files and Tlog
- Number of Logins and Sessions
- Statistics last Updated
Reports
- Backup – Total Size Full Backups
- Backup Report
- Backup Report – All Servers
- Data Allocation per drive
- Data file sizes and free space
- Database Size Totals
- Duration of SQL Jobs
- Failed Job History
- Find If Mix Backup Types are Present
- Growth of Database
- Historical Backup Report
- Link Server Information
- Location of Data files and Tlog
- Location of very last Backups
- Location of very last Backups — All Databases
- Space usage using Mount Points
- SysAdmins on SQL
- Verify Synonyms
Space Issues Scripts
- Backup – Total Size Full Backups
- Batch File to remove Old Files
- Data Allocation per drive
- Data File Size and Free Space – One Database
- Data file sizes and free space
- Database Size Totals
- Free Space on Drives
- Growth of Database
- Last Autogrowth Event
- List Number of Rows per table
- List Space used by tables
- Location of Data files and Tlog
- Shrink a Data File
- Shrink All Transaction Logs
- Shrink TempDB
- Space usage using Mount Points
- SQL Job to delete old files
- VBScript to remove files based on age
Script Generator
- Check When The Last Restore Was Performed
- Enforce Password Policies on SQL Logins
- Generate script to backup all databases
- Rebuild – Reorganize All Indexes
- Restore Full Backup and Tlog Generator
- Restore Generator for all BAK files in one folder
- Restore Script Generator one DB
- Shrink All Transaction Logs
Changing Defaults