Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

The Ultimate Dupe Finder & Performance Test Parameter Set Researcher

By Jesse Roberge,

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
Util_FindHighest
By Jesse Roberge - YeshuaAgapao@Yahoo.com

Finds the largest dupe-sets of one or more columns of a single table or derived table.
Much simpler and much much lower overhead (1 scan total vs 3 scans per column) than Util_GetSelectivity
if you don't need the detailed selectivity analysis for indexes, and
without the dependencies on delimiter functions and a table of numbers.
Great for finding hoggy parameter combinations for performance testing queries (or parts of queries such as corellated subueries or derived tables) within stored procedures!

Required Input Parameters:
@TableName nVarChar(max), Name of the table to analyze. If you want to schema qualify, use 'schema.table'.
Can accept derived table subqueries. feed something like '(SELECT ... FROM ... JOIN ... WHERE ...) AS Table)
@ColumnName nVarChar(4000) Comma separated list of columns to analyze. 'column1' or 'column1,column2'

Optional Input Parameters:
@WhereClause nVarChar(4000)='' Analyze only a subset of a the data in a table. Omit the 'WHERE'
@Top int=25, Select @Top largest dupe sets

Usage:
EXECUTE Util.Util_FindHighest 'dbo.Products', 'FK_IndustryID, FK_CategoryID'

EXECUTE Util.Util_FindHighest
@TableName='
(SELECT Industry.IndustryName, Category.CategoryName, Product.AddDate
FROM dbo.Product JOIN dbo.Industry ON Product.FK_IndustryID=Industry.PK_IndustryID JOIN Category ON Product.FK_CategoryID=Category.PK_CategoryID
) AS ConfigBatches
',
@ColumnName='IndustryName, CategoryName',
@WhereClause='Product.AddDate>GetDate()-30'

Copyright:
Licensed under the L-GPL - a weak copyleft license - you are permitted to use this as a component of a proprietary database and call this from proprietary software.
Copyleft lets you do anything you want except plagiarize, conceal the source, or prohibit copying & re-distribution of this script/proc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

see <http://www.fsf.org/licensing/licenses/lgpl.html> for the license text.

*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

Total article views: 873 | Views in the last 30 days: 2
 
Related Articles
SCRIPT

The Ultimate Prospective-Index Column(s) Selectivity Analyzer

Gets single-column and cumulative-column selectivity stats and @Top largest dupe sets for each cumul...

FORUM

SQL Query of last records(timestamp) for Distinct CategoryId's in same table.

SQL Query of last records(timestamp) for Distinct CategoryId's in same table.

FORUM

Not Selecting All Columns in select query

Not Selecting All Columns in select query

FORUM

SSIS Licensing Question

Licensing

ARTICLE

Total SQL Analyzer Review

Often times, a DBA is asked by clients to document their entire server. This usually includes jobs, ...

Tags
administration    
indexing    
performance tuning    
sql server 2005    
t-sql    
utility    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones