A quick little standalone script that tells you what process is blocking and what processes the blocking processing actually blocking.When running this script in QA, change your output to "Results in Text" ( CTRL-T ). Utilizes the blocking info in sp_who2 combined with dbcc inputbuffer and a little cursor to wrap it all up. Formatting […]
2007-04-19 (first published: 2007-03-20)
7,447 reads
The script details about the workaround for using Dynamic SQL inside T-SQL user defined functions. Basically, T-SQL doesn't allow developers to perform/write any actions/statments which would affect the database's state. As a key note factor for any migration process from oracle to sql server developers need to do a work around on using execute immediate(for […]
2007-04-18 (first published: 2007-03-27)
4,015 reads
spWhatsRunning does just that. It tells you exactly what is executing on your server. By combining the output of the sp_who and dbcc inputbuffer, this script will tell you exactly whats being executed. DBCC INPUTBUFFER will tell you the same thing, but by the time you get the spid, the offending process may be gone. […]
2007-04-17 (first published: 2007-03-20)
2,725 reads
2007-04-16 (first published: 2007-03-20)
14,068 reads
Muestra la ubicacion del Backup mas reciente. Backup completo y backup diferencil de todas las BBDD.Get the location of the recent Backup. Complete Backup and backup diferencil of all the BBDD.
2007-04-13 (first published: 2007-04-02)
775 reads
UDF - SQL 2000 and higherThis function returns an 18 row table of date ranges around a given date.The ranges are: Day, Week (Sunday to Saturday), Month, Quarter, Half Year, Year.For each range there are 3 values: Previous, Same and NextExample of usage:Joined to an orders table:Select r.period, count(o.order_id)from orders oinner join dbo.ufn_date_ranges('2003-04-01') ron o.order_date […]
2007-04-12 (first published: 2003-07-03)
484 reads
In response to Sam Stange's "An old and new way to query Hierarchical data", this script uses the new CTE feature of SQL Server 2005 to display the hierarchical data all at once. I have added a check to prevent infinite loop in case there is a loop in the data (actually, there is one […]
2007-04-11 (first published: 2007-03-28)
1,431 reads
To build function based index in SQL Server, you can use indexed view (materialized view) or using a computed column. In this script, I give an exmaple of how to use the computed column to implement a function based index on a table to search through a free formated telephone number column. The basic step […]
2007-04-10 (first published: 2007-03-29)
8,697 reads
When AUTOSTATS is used in a database, we can sometimes use these automatically generated statistics to find columns where SQL Server has built statistics on non-indexed columns that may benefit from an index. This script finds these columns and displays the selectivity of them. This script can be useful in troubleshooting poorly performing databases by […]
2007-04-09 (first published: 2007-02-20)
1,743 reads
If you use 2 different maintenance plans (one for full-recovery databases and one for simple-mode databases) this proc can help keep the databases in the right plan. You can schedule this as a job and if anyone changes the recovery mode of a database or adds/removes a database, this proc will ensure that the changes […]
2007-04-06 (first published: 2007-03-05)
1,617 reads