SQL and the like

Dave Ballantyne's blog. Freelance SQL Server database designer and developer at Clear Sky SQL

Browse by Tags

All Tags » TSQL » SQLServerPedia Syndication (RSS)
BUG - Use of ranking functions result in an inefficient query plan
In SQL2005 (9.00.4207.00), if you use a ranking function within a view or CTE, then an inefficient query plan can be produced. First off in Adventure works create this index Create Index idxLastName on Person . Contact ( LastName ) and then consider these...
SQL and contiguous data ranges.
As the saying goes "work smarter, not harder", this is definitely the case for SQL. If you have a poorly performing query, then you are not only affecting that one user but diverting precious machine resources needlessly. This is doubly true...
Optimal Query Plans With Unbalanced Data Loads
Sql Server is great at producing and caching efficient query plans.  However these plans may not be the most efficient based upon the parameters passed into subsequent calls off a stored procedure. In this article I am assuming that you have read...
Catch all queries and indexing
Amongst many others, Gail Shaw has blogged on the subject of catch all queries . On many occasions I have needed to do something similar and found performance to be pretty dire on large tables. Typically I would use dynamic SQL to generate the query but...
Another TSQL random length random string generator
The following function function will return you a random string of the specified characters, for a length of between @StrLenLo and @StrLenHi. The only ‘Oddity’ with using this function is that if the parameters are not dependant upon data within a table...