Stored Procedures

sp_RemoveAllConstraintsremoves all constraints on a table, and all foreign keys in other tables referencing this one. To put in Master (all sprocs in Master prefixed with sp_ take the context of the database they're executed in)
check log growthsyou can put this code in a job step, for example, to send a mail whenever the transaction log of a specified database (here tempdb) reach a specific threshold
GetServerUpTimeget time since SQL server is up. The sproc is based on the login datetime of the spid 1, which is a system connection established at startup
CheckCachelist all query plans in cache, ordered by their count of use

User Defined Functions

IsNumbercheck if the parameter is made of numbers. Useful to check if a string represents an integer, instead of IsNumeric that accepts other formats

Perl scripts

During my work as a MS SQL Server DBA, I created a couple of perl scripts to help me automatize some helpful and boring jobs.

ExtractSQLObjectsGenerates scripts from all objects on an entire server, and saves it on disc
checkSQLScriptsUse SQL-DMO to check if all views, sprocs and UDF compile without error in an entire database
table_dependenciesA CGI to search on all objects across databases if a table is referenced. Uses a regular expression to detect the table name. You can use it and look at it as you wish. Please note that the level of security of this script is close to zero. The CGI was not designed to be safe, but to be used internally. Moreover the service running the web server needs to have some rights into SQL Server. I advise to use it only internally

scripts Ruby

Ruby est tellement agréable et clair. Ici un script utilisant SQL-DMO pour extraire le DML des structures d'une base, ou d'un serveur entier:

Voir la description du script à comparaison_python-ruby

 
sql_server/code/index.txt · Dernière modification: 2006/08/03 11:32 (édition externe)