<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - g8rpal</title>
<link>http://snipplr.com/users/g8rpal</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Thu, 23 May 2013 10:22:13 GMT</pubDate>
<item>
<title>(SQL) Suggest Indexes to Add</title>
<link>http://snipplr.com/view/41489/suggest-indexes-to-add/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 05 Oct 2010 06:25:01 GMT</pubDate>
<guid>http://snipplr.com/view/41489/suggest-indexes-to-add/</guid>
</item>
<item>
<title>(SQL) Object Explore</title>
<link>http://snipplr.com/view/41198/object-explore/</link>
<description><![CDATA[ <p>USAGE
First run this script is the database where you want to store this procedure
Then you can run the stored procedure with the following statement:

EXEC sp_ObjectExplore 'database.schema.tablename'

You do not need to supply databasename and schema (example: dbo) when table is in same database as this procedure.

If you want additional metrics concerning the distribution of all numeric variables, execute with parameter @distribution='yes'.
Example:
EXEC sp_ObjectExplore 'database.schema.tablename'
, @distribution='yes'

If you are only interested in a subset of columns, you can specify them in the parameter @columns
Columnnames must be separated by a comma. You can specify them either with or without brackets []
Columnnames may not contain commas.
Example:
EXEC sp_ObjectExplore 'database.schema.tablename'
, @distribution='yes'
, @columns='column1, column2, etc'

PURPOSE
Provide summary information and metrics for any column in a given Table/View
Metrics included are:
* Total number of records in Object (Records)
* Number of values in column (Cnt)
* Number of unique values in column (CntDist)
* Number of NULL values in column (NullValues)
* Min and Max value in column (Min/Max)
* Average value in column (Avg)
* Standard Deviation in column (StDev)
* Number of numeric values in column (IsNum)
* Number of integer values in column (IsInt)
Optional metrics (only computed if procedure is executed with parameter @distribution='yes'
* First Quartile/25% (Q1)
* Median (Median)
* Third Quartile/75% (Q3)
* Interquartile range (IQR)
* Skew (Skew)
* Kurtosis (Kurt)</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:58:50 GMT</pubDate>
<guid>http://snipplr.com/view/41198/object-explore/</guid>
</item>
<item>
<title>(SQL) Index defrag script (21005/2008)</title>
<link>http://snipplr.com/view/41197/index-defrag-script-210052008/</link>
<description><![CDATA[ <p>It can either rebuild/reorg all databases or just a selected database. Options are there to prevent small indexes from being redone (there is not much point in rebuilding an idex with only a few pages). You can also prevent it from reindexing large indexes, one that you may prefer to do manually. If the edition of SQL supports it, it will do online rebuilds. You can also prevent index from being rebuilt that are over a certain threshold, either in pages or percentage (you may want to do manually large indexes manually). 

 

You can set your own threshold for reorg versus rebuild (defaults to 5/30). There is also an option to change the recovery model to simple for the duration of the action.

 

The only time this may fail is if your server is case sensitive, I did not build in the checks to allow for that.

 

If you want to rebuild all indexes with a new fillfactor, just set the @ReOrgThreshold to 1.01 and @ReBuildThreshold to 1.02...or do it manually.

 

Not much else to add, the SP has a good bit of documentation.</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:56:49 GMT</pubDate>
<guid>http://snipplr.com/view/41197/index-defrag-script-210052008/</guid>
</item>
<item>
<title>(SQL) Get daylight savings time</title>
<link>http://snipplr.com/view/41196/get-daylight-savings-time/</link>
<description><![CDATA[ <p>Many of us have come across cases where we need to convert a time (such as UTC) to local time, but what about those parts of the world where daylight savings time is observed?

 

This function will return the daylight savings date/time for a given year in accordance with historical records: http://www.energy.ca.gov/daylightsaving.html#chart

 

This way, no lookup tables are needed. All you have to know is what timezone you are converting from and to, because as long as you have the date when daylight savings begins/ends, then it should be fairly easy to write some case logic to convert the date. This script also contains an example of this function's use by converting UTC to PST.

 

Caveat: The function can return undesirable results if the SET DATEFIRST statement is set to anything other than Sunday.</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:55:30 GMT</pubDate>
<guid>http://snipplr.com/view/41196/get-daylight-savings-time/</guid>
</item>
<item>
<title>(SQL) Delete duplicate rows from the table using row_number()</title>
<link>http://snipplr.com/view/41195/delete-duplicate-rows-from-the-table-using-rownumber/</link>
<description><![CDATA[ <p>To remove the duplicate rows from table we may have used several ways.

In SQL Server 2005 has the feature to delete the duplicate rows within single query.</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:52:52 GMT</pubDate>
<guid>http://snipplr.com/view/41195/delete-duplicate-rows-from-the-table-using-rownumber/</guid>
</item>
<item>
<title>(SQL) Script all Indexes</title>
<link>http://snipplr.com/view/41194/script-all-indexes/</link>
<description><![CDATA[ <p>This script will generate CREATE Index statements for all indexes in the database</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:50:42 GMT</pubDate>
<guid>http://snipplr.com/view/41194/script-all-indexes/</guid>
</item>
<item>
<title>(SQL) Way to Check Multiple LIKE without dynamic SQL</title>
<link>http://snipplr.com/view/41192/way-to-check-multiple-like-without-dynamic-sql/</link>
<description><![CDATA[ <p>This uses CROSS APPLY and the fn_split() function to separate out parameters. The @vParam parameter stores your LIKE conditions, separated by commas.
By Atif-ullah Sheikh, 2010/09/16</p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:39:08 GMT</pubDate>
<guid>http://snipplr.com/view/41192/way-to-check-multiple-like-without-dynamic-sql/</guid>
</item>
<item>
<title>(SQL) List all columns in server</title>
<link>http://snipplr.com/view/41191/list-all-columns-in-server/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 30 Sep 2010 22:27:02 GMT</pubDate>
<guid>http://snipplr.com/view/41191/list-all-columns-in-server/</guid>
</item>
<item>
<title>(SQL) Autogenerate identity column via Select</title>
<link>http://snipplr.com/view/40246/autogenerate-identity-column-via-select/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 10 Sep 2010 05:35:01 GMT</pubDate>
<guid>http://snipplr.com/view/40246/autogenerate-identity-column-via-select/</guid>
</item>
<item>
<title>(SQL) Delete duplicate rows from the table using row_number()</title>
<link>http://snipplr.com/view/40096/delete-duplicate-rows-from-the-table-using-rownumber/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 07 Sep 2010 21:43:04 GMT</pubDate>
<guid>http://snipplr.com/view/40096/delete-duplicate-rows-from-the-table-using-rownumber/</guid>
</item>
<item>
<title>(SQL) Script all Foreign Key Constraints - Result Set can be used to DROP constraints for 'TableName'</title>
<link>http://snipplr.com/view/39932/script-all-foreign-key-constraints--result-set-can-be-used-to-drop-constraints-for-tablename/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 03 Sep 2010 04:06:08 GMT</pubDate>
<guid>http://snipplr.com/view/39932/script-all-foreign-key-constraints--result-set-can-be-used-to-drop-constraints-for-tablename/</guid>
</item>
<item>
<title>(SQL) Script all Foreign Key Constraints - Result Set can be used to copy constraints to your testing DB or to keep on hand in case of</title>
<link>http://snipplr.com/view/39931/script-all-foreign-key-constraints--result-set-can-be-used-to-copy-constraints-to-your-testing-db-or-to-keep-on-hand-in-case-of/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 03 Sep 2010 04:00:30 GMT</pubDate>
<guid>http://snipplr.com/view/39931/script-all-foreign-key-constraints--result-set-can-be-used-to-copy-constraints-to-your-testing-db-or-to-keep-on-hand-in-case-of/</guid>
</item>
<item>
<title>(SQL) SQL SERVER – 2005 – Find Tables With Foreign Key Constraint in Database</title>
<link>http://snipplr.com/view/39930/sql-server--2005--find-tables-with-foreign-key-constraint-in-database/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 03 Sep 2010 03:52:46 GMT</pubDate>
<guid>http://snipplr.com/view/39930/sql-server--2005--find-tables-with-foreign-key-constraint-in-database/</guid>
</item>
<item>
<title>(SQL) only select date part from datetime</title>
<link>http://snipplr.com/view/39757/only-select-date-part-from-datetime/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 31 Aug 2010 21:55:32 GMT</pubDate>
<guid>http://snipplr.com/view/39757/only-select-date-part-from-datetime/</guid>
</item>
</channel>
</rss>