Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library of Useful (Difficult) SQL scripts [closed]

Tags:

sql

scripting

People also ask

How do I view blocked history in SQL Server?

Using system_health extended event to monitor SQL Server blocking problems. The system_health is the default extended event session of the SQL Server. It is started automatically when the database engine is started. The system_health captures any session that has waited in the blocked status for over 30 seconds.


You may find this wiki on LessThanDot useful, for the most part, it is by Denis Gobo, Microsoft SQL MVP.

EDIT: The wiki includes 100+ SQL Server Programming Hacks, the list is, I think, too long to include here, however, there is a comprehensive index.

Also available from the same site: SQL Server Admin Hacks.


Here are a few that I find very useful:

  • SQL Server Best Practices - Microsoft SQL Server White Papers and Best Practices
  • vyaskn - A mixture of articles From DBA to Developer
  • Backup, Integrity Check and Index Optimization
  • SQLServerCentral Scripts - Scripts for most most DBA tasks and more
  • Script Repository: SQL Server 2005 - TechNet Script Center
  • Scripts and Tools for Performance Tuning and Troubleshooting SQL Server 2005
  • SQL Server Query Processing Team - Hardcore advice from the MS SQL optimisation team
  • Common Solutions for T-SQL Problems
  • Davide Mauri's Index Scripts

Some Administration stuff

Glenn Berry: Five Very Useful Index Selection Queries for SQL Server 2005

  • Find "Missing" Indexes for the entire instance of SQL Server
  • Find "Missing" Indexes for a single table
  • Examine the current index structure for a single table
  • Look at index usage for a single table
  • Look for possible bad indexes inside the entire current database
  • Drill into your workload (Bonus)

SQL Server Central: Seven Monitoring Scripts

  • Failed jobs report
  • Free space by drive
  • Disabled jobs
  • Running jobs
  • Server role members
  • Last backup date
  • SQL Log

And last, but not least this resource: SQL Server Programming Hacks - 100+ List


Joe Celko's SQL Puzzles and Answers

The Art of SQL (slight Oracle bias)


Sql Cookbook has a variety of interesting example, though some will undoubtedly be unsupported by your RDBMS of choice. O'Reilly also has a T-SQL Cookbook, but I've never personally read it.