<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Strate SQL &#187; T-SQL</title>
	<atom:link href="http://www.jasonstrate.com/index.php/category/t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonstrate.com</link>
	<description>Questions, answers, opinions and scripts from a SQL Server DBA</description>
	<lastBuildDate>Wed, 08 Sep 2010 13:30:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Find Tables and Columns by Data Type</title>
		<link>http://www.jasonstrate.com/index.php/2010/08/find-tables-and-columns-by-data-type/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/08/find-tables-and-columns-by-data-type/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 20:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/08/find-tables-and-columns-by-data-type/</guid>
		<description><![CDATA[A couple weeks back someone asked me some questions about data types.  Apparently, while implementing some financial data, each developer on the project had chosen their own data type.  This was a bit of a problem that can lead to serious problems.  When financial data is rounded unexpectedly &#8211; bad things can sometimes happen and [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F08%2Ffind-tables-and-columns-by-data-type%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F08%2Ffind-tables-and-columns-by-data-type%2F" height="61" width="51" /></a></div><p><a title="old yellow eyes" href="http://www.flickr.com/photos/9450118@N03/4896224541/"><img style="display: inline; margin-left: 0px; margin-right: 0px;" src="http://static.flickr.com/4099/4896224541_14cf887469.jpg" border="0" alt="old yellow eyes" width="142" height="167" align="right" /></a>A couple weeks back someone asked me some questions about data types.  Apparently, while implementing some financial <a href="http://en.wikipedia.org/wiki/Data_(Star_Trek)">data</a>, each developer on the project had chosen their own data type.  This was a bit of a problem that can lead to serious problems.  When financial data is rounded unexpectedly &#8211; <a href="http://en.wikipedia.org/wiki/Superman_III">bad things can sometimes happen and it usually doesn’t involve plots for half pennies</a>.</p>
<p>Anyways, I advised that it might be a good idea to get all of the data types on these columns aligned. To do this I provided them with a couple scripts that are below that they used to find the occurrences of this information.  These scripts both use the <a href="http://msdn.microsoft.com/en-us/library/ms176106.aspx">sys.columns</a> and <a href="http://msdn.microsoft.com/en-us/library/ms188021.aspx">sys.types</a> catalog views.</p>
<p>This first script, pulls out all of the columns that are in the database using decimal, numeric, or money data type.  It includes a filter where scale is not equal to zero – which should have included all of the financial data.</p>
<pre class="brush: sql; ">
SELECT OBJECT_NAME(c.object_id) as table_name
    , c.name
    , t.name
    , c.precision
    , c.scale
FROM sys.columns c
    INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE t.name IN (&#039;decimal&#039;,&#039;numeric&#039;,&#039;money&#039;)
AND c.scale &lt;&gt; 0
ORDER BY 1, 2
</pre>
<p>The second script lists all of the columns of a specific name with their table and data type information.</p>
<pre class="brush: sql; ">
SELECT OBJECT_NAME(c.object_id) as table_name
    , c.name
    , t.name
    , c.precision
    , c.scale
FROM sys.columns c
    INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE c.name = &#039;ListPrice&#039;
ORDER BY 1, 2
</pre>
<p>Through the use of these and similar scripts, columns and the tables that they are in can be easily determined.  And this information can be found using either the data type or the name of the column.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/08/find-tables-and-columns-by-data-type/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PASSMN July Meeting Today</title>
		<link>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 14:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/</guid>
		<description><![CDATA[
Don’t forget the July PASSMN meeting is today.&#160; We have Itzik Ben-Gan (blog) coming in to talk about some query tuning tips.
Here are the meeting details…
Date and&#160; Time:
July 20, 2010, 5:00 PM CST
Location: 
8300 Norman Center Drive, 9th Floor, Bloomington, MN&#160; 55437 (map)
Live Meeting

URL: https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&#38;role=attend&#38;pw=h*ZR%248%25%2Fd 
Meeting ID: 7DGRT6 
Entry Code: h*ZR$8%/d

Agenda:

5:00 –5:15 : Announcements  [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Next Week'>PASSMN July Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Announced'>July PASSMN Meeting Announced</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fpassmn-july-meeting-today%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fpassmn-july-meeting-today%2F" height="61" width="51" /></a></div><p><a href="http://minnesota.sqlpass.org"><img style="display: inline; margin-left: 0px; margin-right: 0px" alt="Minnesota SQL Server Users Group" align="right" src="http://minnesota.sqlpass.org/Portals/61/logo.gif" width="177" height="71" /></a></p>
<p>Don’t forget the July PASSMN meeting is today.&#160; We have Itzik Ben-Gan (<a href="http://blogs.solidq.com/ibengan/Home.aspx">blog</a>) coming in to talk about some query tuning tips.</p>
<p>Here are the meeting details…</p>
<blockquote><p><strong>Date and&#160; Time:</strong></p>
<p>July 20, 2010, 5:00 PM CST</p>
<p><b>Location: </b></p>
<p>8300 Norman Center Drive, 9th Floor, Bloomington, MN&#160; 55437 (<a href="http://www.bing.com/maps/OneClickDirections.aspx?rtp=%7epos.rg82g976mkjn_8300+Norman+Center+Dr%2c+Bloomington%2c+MN+55437-1027___a_&amp;rsd=44.875722527504_-93.3967977762222__the+north+(on+US-169+S)%7e44.8308277130127_-93.2932215929031__the+south+(on+I-35W+N)%7e44.8620003461838_-93.2855504751205__the+east+(on+I-494+W+%2f+SR-5+W)%7e44.8592001199722_-93.4069204330444__the+west+(on+I-494+E+%2f+SR-5+E)&amp;mkt=en-us&amp;FORM=LLMP">map</a>)</p>
<p><b>Live Meeting</b></p>
<ul>
<li>URL: <a href="https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd">https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd</a> </li>
<li>Meeting ID: 7DGRT6 </li>
<li>Entry Code: h*ZR$8%/d</li>
</ul>
<p><b>Agenda:</b></p>
</p>
<p>5:00 –5:15 : Announcements     <br />5:15 –5:25 : Sponsor      <br />5:25 –6:45 : Query Tuning Tips (Itzik)      <br />6:45 –7:00 : Survey Collection and Giveaways</p>
</blockquote>
<p><b>Presentation:</b> </p>
<blockquote><p><b>Query Tuning Tips</b> </p>
<p>Given a SQL Server querying problem there&#8217;s much that you can do to enable a good performing solution. Tuning involves arranging an optimal physical environment, e.g., by creating supporting indexes, as well as writing the query in a way that it would get an optimal execution plan. Many factors can affect the efficiency of the solution including the availability of indexes, data distribution and density, and others. In different scenarios, a different solution could be the most efficient for the same querying problem. Query tuning could be considered an art. This session will provide various tips to do efficient query tuning and demonstrate those through specific tuning examples. </p>
<p><b>Itzik Ben-Gan</b> is a Mentor and Co-Founder of Solid Quality Mentors. A SQL Server Microsoft MVP (Most Valuable Professional) since 1999, Itzik has delivered numerous training events around the world focused on T-SQL Querying, Query Tuning and Programming. Itzik is the author of several books including Microsoft SQL Server 2008: T-SQL Fundamentals, Inside Microsoft SQL Server 2008: T-SQL Querying and Inside Microsoft SQL Server 2008: T-SQL Programming. He has written many articles for SQL Server Magazine as well as articles and whitepapers for MSDN. Itzik&#8217;s speaking activities include TechEd, DevWeek, SQLPASS, SQL Server Magazine Connections, various user groups around the world, and Solid Quality Mentors&#8217; events to name a few. Itzik is the author of Solid Quality Mentors&#8217; Advanced T-SQL Querying, Programming and Tuning and T-SQL Fundamentals courses along with being a primary resource within the company for their T-SQL related activities</p>
</blockquote>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Next Week'>PASSMN July Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Announced'>July PASSMN Meeting Announced</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PASSMN July Meeting Next Week</title>
		<link>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 13:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/</guid>
		<description><![CDATA[
The July PASSMN meeting is is coming up next week.&#160; If you’ve not registered now’s a great time to get your RSVP in.&#160; We have Itzik Ben-Gan (blog) coming in to talk about some query tuning tips.
Here are the meeting details…
Date and&#160; Time:
July 20, 2010, 5:00 PM CST
Location: 
8300 Norman Center Drive, 9th Floor, Bloomington, [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Today'>PASSMN July Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Announced'>July PASSMN Meeting Announced</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fpassmn-july-meeting-next-week%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fpassmn-july-meeting-next-week%2F" height="61" width="51" /></a></div><p><a href="http://minnesota.sqlpass.org"><img style="display: inline; margin-left: 0px; margin-right: 0px" alt="Minnesota SQL Server Users Group" align="right" src="http://minnesota.sqlpass.org/Portals/61/logo.gif" width="177" height="71" /></a></p>
<p>The July PASSMN meeting is is coming up next week.&#160; If you’ve not registered now’s a great time to <a href="http://www.sqlpass.org/Events/ctl/ViewEvent/mid/521.aspx?ID=442">get your RSVP in</a>.&#160; We have Itzik Ben-Gan (<a href="http://blogs.solidq.com/ibengan/Home.aspx">blog</a>) coming in to talk about some query tuning tips.</p>
<p>Here are the meeting details…</p>
<blockquote><p><strong>Date and&#160; Time:</strong></p>
<p>July 20, 2010, 5:00 PM CST</p>
<p><b>Location: </b></p>
<p>8300 Norman Center Drive, 9th Floor, Bloomington, MN&#160; 55437 (<a href="http://www.bing.com/maps/OneClickDirections.aspx?rtp=%7epos.rg82g976mkjn_8300+Norman+Center+Dr%2c+Bloomington%2c+MN+55437-1027___a_&amp;rsd=44.875722527504_-93.3967977762222__the+north+(on+US-169+S)%7e44.8308277130127_-93.2932215929031__the+south+(on+I-35W+N)%7e44.8620003461838_-93.2855504751205__the+east+(on+I-494+W+%2f+SR-5+W)%7e44.8592001199722_-93.4069204330444__the+west+(on+I-494+E+%2f+SR-5+E)&amp;mkt=en-us&amp;FORM=LLMP">map</a>)</p>
<p><b>Live Meeting</b></p>
<ul>
<li>URL: <a href="https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd">https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd</a></li>
<li>Meeting ID: 7DGRT6 </li>
<li>Entry Code: h*ZR$8%/d</li>
</ul>
<p><b>Agenda:</b></p>
</p>
<p>5:00 –5:15 : Announcements     <br />5:15 –5:25 : Sponsor      <br />5:25 –6:45 : Query Tuning Tips (Itzik)      <br />6:45 –7:00 : Survey Collection and Giveaways</p>
</blockquote>
<p><b>Presentation:</b> </p>
<blockquote><p><b>Query Tuning Tips</b></p>
<p>Given a SQL Server querying problem there&#8217;s much that you can do to enable a good performing solution. Tuning involves arranging an optimal physical environment, e.g., by creating supporting indexes, as well as writing the query in a way that it would get an optimal execution plan. Many factors can affect the efficiency of the solution including the availability of indexes, data distribution and density, and others. In different scenarios, a different solution could be the most efficient for the same querying problem. Query tuning could be considered an art. This session will provide various tips to do efficient query tuning and demonstrate those through specific tuning examples.</p>
<p><b>Itzik Ben-Gan</b> is a Mentor and Co-Founder of Solid Quality Mentors. A SQL Server Microsoft MVP (Most Valuable Professional) since 1999, Itzik has delivered numerous training events around the world focused on T-SQL Querying, Query Tuning and Programming. Itzik is the author of several books including Microsoft SQL Server 2008: T-SQL Fundamentals, Inside Microsoft SQL Server 2008: T-SQL Querying and Inside Microsoft SQL Server 2008: T-SQL Programming. He has written many articles for SQL Server Magazine as well as articles and whitepapers for MSDN. Itzik&#8217;s speaking activities include TechEd, DevWeek, SQLPASS, SQL Server Magazine Connections, various user groups around the world, and Solid Quality Mentors&#8217; events to name a few. Itzik is the author of Solid Quality Mentors&#8217; Advanced T-SQL Querying, Programming and Tuning and T-SQL Fundamentals courses along with being a primary resource within the company for their T-SQL related activities</p>
</blockquote>
<p><font size="4"><a href="http://www.sqlpass.org/Events/ctl/ViewEvent/mid/521.aspx?ID=442">Please RSVP here if you will be attending in person, this helps us understand how many people to tell the sponsor to get food for.</a></font></p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Today'>PASSMN July Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Announced'>July PASSMN Meeting Announced</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Webcast Today &#8211; Performance Impacts Related to Different Function Types</title>
		<link>http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 14:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/</guid>
		<description><![CDATA[I’ll be speaking for the SQL PASS Performance Virtual Chapter later today starting at 12 PM Eastern time.  The topic will be Performance Impacts Related to Different Function Types.  The abstract for the event is the following:
User defined functions provide a means to encapsulate business logic in the database tier.  Often the purpose of the [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Spring &#8216;10 Ultimate Virtual Conference'>SSWUG Spring &#8216;10 Ultimate Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-next-week-using-xml-to-query-execution-plans/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Using XML to Query Execution Plans'>Webcast Next Week &#8211; Using XML to Query Execution Plans</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fwebcast-today-performance-impacts-related-to-different-function-types%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F07%2Fwebcast-today-performance-impacts-related-to-different-function-types%2F" height="61" width="51" /></a></div><p>I’ll be speaking for the <a href="http://www.sqlpass.org/">SQL PASS</a> <a href="http://performance.sqlpass.org/">Performance Virtual Chapter</a> later today starting at 12 PM Eastern time.  The topic will be <a href="https://www323.livemeeting.com/cc/usergroups/join?id=3CF2HR&amp;role=attend&amp;pw=S`w-~7\6b">Performance Impacts Related to Different Function Types</a>.  The abstract for the event is the following:</p>
<blockquote><p>User defined functions provide a means to encapsulate business logic in the database tier.  Often the purpose of the encapsulation is to provide standard method access segments of data within the database.  Unfortunately, not all methods of creating user defined functions are equal.  In this session we’ll review the types of user defined functions and investigate the performance impact in selecting the different types</p>
<p><strong>Goals:</strong></p>
<ul>
<li>Identify purposes for creating user defined functions</li>
<li>Discuss the types of user-defined functions</li>
<li>Demonstrate performance impact in selecting different types of functions</li>
</ul>
</blockquote>
<p>You can get to the event <a href="https://www323.livemeeting.com/cc/usergroups/join?id=3CF2HR&amp;role=attend&amp;pw=S`w-~7\6b">here</a>.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Spring &#8216;10 Ultimate Virtual Conference'>SSWUG Spring &#8216;10 Ultimate Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-next-week-using-xml-to-query-execution-plans/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Using XML to Query Execution Plans'>Webcast Next Week &#8211; Using XML to Query Execution Plans</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>July PASSMN Meeting Announced</title>
		<link>http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 17:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/</guid>
		<description><![CDATA[Sometimes when we are putting together the user group meetings things change.&#160; Opportunities arise and we get a chance to take a cool meeting and turn it into a great meeting.&#160; That happened with this months meeting and it’s going to be great.
A couple things are different for this month… time and topic.&#160; This month [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Next Week'>PASSMN July Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Today'>PASSMN July Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F06%2Fjuly-passmn-meeting-announced%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F06%2Fjuly-passmn-meeting-announced%2F" height="61" width="51" /></a></div><p><a title="Lego Deadlock" href="http://www.flickr.com/photos/in-duce/2232109985/"><img style="margin: 0px 0px 5px 5px; display: inline" border="0" alt="Lego Deadlock" align="right" src="http://farm3.static.flickr.com/2102/2232109985_44161783c0.jpg" width="199" height="132" /></a>Sometimes when we are putting together the user group meetings things change.&#160; Opportunities arise and we get a chance to take a cool meeting and turn it into a great meeting.&#160; That happened with this months meeting and it’s going to be great.</p>
<p>A couple things are different for this month… time and topic.&#160; This month instead of meeting at 3:00 PM we are meeting at 5:00 PM.&#160; And the reason for the change is that we have Itzik Ben-Gan (<a href="http://blogs.solidq.com/ibengan/Home.aspx">blog</a>) stopping by for a presentation.</p>
<h2>The Presentation</h2>
<p>This month he’ll be teaching a course at <a href="http://www.benchmarklearning.com/Courses/CrsDetail.aspx?C=SQMTASQLPrg08">Benchmark Learning</a>.&#160; His course is <a href="http://www.solidq.com/squ/courses/Pages/Advanced%20T-SQL%20Querying,%20Programming%20and%20Tuning%20for%20SQL%20Server%202005%20and%202008.aspx">Advanced T-SQL Querying, Programming and Tuning for SQL Server 2005 &amp; 2008</a>.&#160; If you want more than what you suspect will be at the meeting, then this class is for you.</p>
<p>What can you suspect will be at the meeting this month?&#160; Well, how about this?</p>
<blockquote><p><b>Query Tuning Tips</b></p>
<p>Given a SQL Server querying problem there&#8217;s much that you can do to enable a good performing solution. Tuning involves arranging an optimal physical environment, e.g., by creating supporting indexes, as well as writing the query in a way that it would get an optimal execution plan. Many factors can affect the efficiency of the solution including the availability of indexes, data distribution and density, and others. In different scenarios, a different solution could be the most efficient for the same querying problem. Query tuning could be considered an art. This session will provide various tips to do efficient query tuning and demonstrate those through specific tuning examples.</p>
</blockquote>
<p>Pretty cool stuff, eh?</p>
<h2>And the Rest of the Details…</h2>
<p>This month’s meeting sponsor is <a href="http://www.digineer.com/">Digineer</a>.&#160; They’ll be providing the food and beverages.&#160; Digineer happens to be my employer and if you’re local and looking for a company with talent and skill this is a good place to look. </p>
<blockquote><p><strong>Date: </strong>July 20, 2010     <br /><strong>Time: </strong>5:00 PM – 7:00 PM     <br /><strong>Location: </strong>8300 Norman Center Drive, 9th Floor, Bloomington, MN&#160; 55437     <br /><strong>Live Meeting</strong>
<ul>
<li><strong>URL: </strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd">https://www.livemeeting.com/cc/usergroups/join?id=7DGRT6&amp;role=attend&amp;pw=h*ZR%248%25%2Fd</a> </li>
<li><b>Meeting ID: </b>7DGRT6 </li>
<li><b>Entry Code: </b>h*ZR$8%/d </li>
</ul>
<p><a href="http://www.sqlpass.org/Events/ctl/ViewEvent/mid/521.aspx?ID=442">The all important RSVP link – please do RSVP so that we’ll have enough food for the event.</a></p>
</blockquote>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-next-week/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Next Week'>PASSMN July Meeting Next Week</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/passmn-july-meeting-today/' rel='bookmark' title='Permanent Link: PASSMN July Meeting Today'>PASSMN July Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/07/july-passmn-meeting-next-week-july-14/' rel='bookmark' title='Permanent Link: July PASSMN Meeting Next Week (July 14)'>July PASSMN Meeting Next Week (July 14)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/06/july-passmn-meeting-announced/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</title>
		<link>http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 17:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/</guid>
		<description><![CDATA[I’ll be speaking for the SQL PASS Performance Virtual Chapter next week.&#160; It’ll be on July 6 at 12 PM Eastern time.&#160; The topic will be Performance Impacts Related to Different Function Types.&#160; The abstract for the event is the following: 
User defined functions provide a means to encapsulate business logic in the database tier.&#160; [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Today &#8211; Performance Impacts Related to Different Function Types'>Webcast Today &#8211; Performance Impacts Related to Different Function Types</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Spring &#8216;10 Ultimate Virtual Conference'>SSWUG Spring &#8216;10 Ultimate Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-next-week-using-xml-to-query-execution-plans/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Using XML to Query Execution Plans'>Webcast Next Week &#8211; Using XML to Query Execution Plans</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F06%2Fwebcast-next-week-performance-impacts-related-to-different-function-types%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F06%2Fwebcast-next-week-performance-impacts-related-to-different-function-types%2F" height="61" width="51" /></a></div><p>I’ll be speaking for the <a href="http://www.sqlpass.org/">SQL PASS</a> <a href="http://performance.sqlpass.org/">Performance Virtual Chapter</a> next week.&#160; It’ll be on July 6 at 12 PM Eastern time.&#160; The topic will be Performance Impacts Related to Different Function Types.&#160; The abstract for the event is the following: </p>
<blockquote><p>User defined functions provide a means to encapsulate business logic in the database tier.&#160; Often the purpose of the encapsulation is to provide standard method access segments of data within the database.&#160; Unfortunately, not all methods of creating user defined functions are equal.&#160; In this session we’ll review the types of user defined functions and investigate the performance impact in selecting the different types</p>
<p><strong>Goals:</strong></p>
<ul>
<li>Identify purposes for creating user defined functions </li>
<li>Discuss the types of user-defined functions </li>
<li>Demonstrate performance impact in selecting different types of functions </li>
</ul>
</blockquote>
<p>You can get to the event <a href="https://www323.livemeeting.com/cc/usergroups/join?id=3CF2HR&amp;role=attend&amp;pw=S`w-~7\6b">here</a>.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-today-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Today &#8211; Performance Impacts Related to Different Function Types'>Webcast Today &#8211; Performance Impacts Related to Different Function Types</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Spring &#8216;10 Ultimate Virtual Conference'>SSWUG Spring &#8216;10 Ultimate Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/07/webcast-next-week-using-xml-to-query-execution-plans/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Using XML to Query Execution Plans'>Webcast Next Week &#8211; Using XML to Query Execution Plans</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Doing Something About Auto Generated Names</title>
		<link>http://www.jasonstrate.com/index.php/2010/05/doing-something-about-auto-generated-names/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/05/doing-something-about-auto-generated-names/#comments</comments>
		<pubDate>Wed, 26 May 2010 17:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/05/doing-something-about-auto-generated-names/</guid>
		<description><![CDATA[I like my name.  It provides a point of reference to who I am.  If I am at work and someone calls for “Jason Strate”… that’s me.  If I am at home, the same thing can happen and I still know that it’s me.  I know that no matter where I am, my name will [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F05%2Fdoing-something-about-auto-generated-names%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F05%2Fdoing-something-about-auto-generated-names%2F" height="61" width="51" /></a></div><p><a title="Zombie Apocafest 2009 - Shaun &amp; Ed" href="http://www.flickr.com/photos/12426416@N00/3982315713/"><img style="margin: 0px 0px 5px 5px; display: inline;" src="http://static.flickr.com/2668/3982315713_fb262e22e1.jpg" border="0" alt="Zombie Apocafest 2009 - Shaun &amp; Ed" width="199" height="132" align="right" /></a>I like my name.  It provides a point of reference to who I am.  If I am at work and someone calls for “Jason Strate”… that’s me.  If I am at home, the same thing can happen and I still know that it’s me.  I know that no matter where I am, my name will be a constant and it means something when it is called.  <span style="text-decoration: line-through;">Hopefully, it doesn’t mean “late to dinner”.</span></p>
<p>This same principle applies to the tables and the objects related to those tables.  We give that table a name in the development environment, maybe it’s called “ZombieBaconUnicorn”.  We expect that it will be called “ZombieBaconUnicorn”.  Unfortunately, this doesn’t always ring true with other database objects related to tables; such as Primary Keys and Defaults Constraints.</p>
<h2>Random Naming</h2>
<p>There are multiple ways to create Primary Key and Default Constraints and they don’t all have an implied name.  Take for instance the following script, what would you assume the names of the Primary Key and Default Constraints would be?</p>
<pre class="brush: sql; ">
CREATE TABLE dbo.RandomPKandDC
(
RandomPKandDCID int IDENTITY(1,1) PRIMARY KEY CLUSTERED
,Column1 datetime DEFAULT(GETDATE())
)

SELECT name FROM sys.objects
WHERE parent_object_id = OBJECT_ID(&#039;dbo.RandomPKandDC&#039;)
</pre>
<p>Did you guess the following names?</p>
<p><a href="http://www.jasonstrate.com/wp-content/uploads/2010/05/image.png"><img style="display: inline; border: 0px;" title="image" src="http://www.jasonstrate.com/wp-content/uploads/2010/05/image_thumb.png" border="0" alt="image" width="242" height="62" /></a></p>
<p>No?!  Run it on you machine, you’ll get your own unique names.</p>
<h2>Non-Random Naming</h2>
<p>Getting around the random naming is pretty simple.  Below I’ll would you through the steps.</p>
<p>The first change is how you’ll define the PRIMARY KEY on the table with the <a href="http://msdn.microsoft.com/en-us/library/ms174979.aspx">CREATE TABLE</a> statement.  Instead of adding PRIMARY KEY CLUSTERED on the column definition, add it to the table as a constraint.</p>
<pre class="brush: sql; ">
CREATE TABLE dbo.NonRandomPKandDC
(
NonRandomPKandDCID int IDENTITY(1,1)
,Column1 datetime
,CONSTRAINT PK_NonRandomPKandDC_RandomPKandDCID PRIMARY KEY CLUSTERED (NonRandomPKandDCID)
)
</pre>
<p>Next you want to use the ALTER TABLE statement to add the DEFAULT CONSTRAINT.  Instead of making the default part of the column definition in the CREATE TABLE, you want to name the default as a constraint to name it as it is created.</p>
<pre class="brush: sql; ">
ALTER TABLE dbo.NonRandomPKandDC ADD CONSTRAINT DF_NonRandomPKandDC_Column1
DEFAULT (getdate()) FOR [Column1]
</pre>
<p>Take a look at the results of the next query:</p>
<pre class="brush: sql; ">
SELECT name FROM sys.objects
WHERE parent_object_id = OBJECT_ID(&#039;dbo.NonRandomPKandDC&#039;)
</pre>
<p><a href="http://www.jasonstrate.com/wp-content/uploads/2010/05/image1.png"><img style="display: inline; border: 0px;" title="image" src="http://www.jasonstrate.com/wp-content/uploads/2010/05/image_thumb1.png" border="0" alt="image" width="270" height="59" /></a></p>
<p>On your server and mine the objects will have the same name.  When you deploy objects build from T-SQL like this from development to test to production they will have the same names.</p>
<h2>What the!?</h2>
<p>Now there isn’t anything wrong with these random names from the perspective of how your database will perform.  But it will hose up things such as database comparisons and investigating errors.</p>
<p>With database comparisons, the issue is pretty obvious.  If the contents of the object are the same but the name is different then it isn’t the exact same object.  Many tools have options for ignoring these names, but there are some that don’t.  Even when the tool has the option to ignore, you will need to rely on the operator of the tool to disable the feature.</p>
<p>Looking now at investigating errors, I am a big fan of errors that can tell me the problem within the database.  Which of the following is easier to understand.  The first with the random name:</p>
<blockquote><p>Msg 2627, Level 14, State 1, Line 2<br />
Violation of PRIMARY KEY constraint &#8216;PK__RandomPKandDC__5D60DB10&#8242;. Cannot insert duplicate key in object &#8216;dbo.RandomPKandDC&#8217;.<br />
The statement has been terminated.</p></blockquote>
<p>Or the second with the stated name:</p>
<blockquote><p>Msg 2627, Level 14, State 1, Line 2<br />
Violation of PRIMARY KEY constraint &#8216;PK_NonRandomPKandDC_RandomPKandDCID&#8217;. Cannot insert duplicate key in object &#8216;dbo.NonRandomPKandDC&#8217;.<br />
The statement has been terminated.</p></blockquote>
<p>Ok, maybe this isn’t the best example of this type of issue, but it does tell me exactly the issue and because I named the object explicitly I know where the problem is and something about the issue before digging into the schema of the table.</p>
<p>Overall, this is about reducing pain points in building and using your databases.  The easier it is to manage them once they are deployed, the more Bejeweled Blitz you can play on <a href="http://www.facebook.com/StrateSQL">Facebook</a> between your projects.</p>
<h2>Renaming the Objects</h2>
<p>Maybe I’ve sold you on this idea.  If so, you may be thinking “What the heck do you do with all of my existing databases objects?”  That answer is simple… rename them.  Since the names of these objects isn’t tied to how they are defined, you can easily get them renamed with <a href="http://msdn.microsoft.com/en-us/library/ms188351.aspx">sp_rename</a>.</p>
<p>The following two scripts are what I use to rename PRIMARY KEY CONSTRAINTS and DEFAULT CONSTRAINTS.</p>
<p>This first one will provide sp_rename statements that you can execute to rename all of your PRIMARY KEY CONSTRAINTS:</p>
<pre class="brush: sql; ">
;WITH PKNames
AS (
SELECT name AS IndexName
,OBJECT_NAME(object_id) AS TableName
,OBJECT_SCHEMA_NAME(object_id) as SchemaName
,(SELECT &#039;&#039; + c.name
FROM sys.index_columns ic
INNER JOIN sys.columns c
ON ic.object_id = c.object_id
AND ic.index_column_id = c.column_id
WHERE ic.object_id = i.object_id
AND ic.index_id = i.index_id
AND ic.is_included_column = 0
ORDER BY ic.key_ordinal
FOR XML PATH(&#039;&#039;)) AS Columns
FROM sys.indexes i
WHERE i.is_primary_key = 1
)
SELECT &#039;EXEC sp_rename &#039;&#039;&#039; + QUOTENAME(SchemaName) + &#039;.&#039; + QUOTENAME(IndexName) + &#039;&#039;&#039;, &#039;&#039;PK_&#039; + TableName + &#039;_&#039; + Columns + &#039;&#039;&#039;&#039;
FROM PKNames
WHERE IndexName &lt;&gt; &#039;PK_&#039; + TableName + &#039;_&#039; + Columns
</pre>
<p>The second one will provide sp_rename statements that you can execute to rename all of your DEFAULT CONSTRAINTS:</p>
<pre class="brush: sql; ">
SELECT &#039;EXEC sp_rename &#039;&#039;&#039; + QUOTENAME(OBJECT_SCHEMA_NAME(dc.parent_object_id)) + &#039;.&#039;
+ QUOTENAME(dc.name) + &#039;&#039;&#039;, &#039;&#039;DF_&#039; + OBJECT_NAME(dc.parent_object_id) + &#039;_&#039; + c.name + &#039;&#039;&#039;&#039;
FROM sys.default_constraints dc
INNER JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
WHERE dc.name &lt;&gt; &#039;DF_&#039; + OBJECT_NAME(dc.parent_object_id) + &#039;_&#039; + c.name
</pre>
<p>Hopefully these can be helpful for you as well.</p>
<h2>Conclusion</h2>
<p>In a roundabout way, this post has been about naming conventions.  Make the world a prettier place by having a convention on naming the objects in your database.</p>
<p>Last word… don’t just run out and use this in your production database without doing your own testing and promoting using your own company’s deployment process.  An obvious statement but one that I thought I should point out since I know how tempting this can be.</p>
<p>EDIT 2010/05/27: Modified scripts to account for schema variations.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/05/doing-something-about-auto-generated-names/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>The Power of N</title>
		<link>http://www.jasonstrate.com/index.php/2010/04/the-power-of-n/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/04/the-power-of-n/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 13:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/04/the-power-of-n/</guid>
		<description><![CDATA[A peer the other day was having some trouble storing some some Chinese characters in a database.  Every time he would insert the data into his table, the results would look similar to the following.

The phrase he was adding was similar to the following:
烟肉独角兽彩虹乳酪
The T-SQL he was using was forwarded to me and it looked [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2006/05/this-blog-entry-brought-to-you-by-the-procedure-sp_msforeachdb/' rel='bookmark' title='Permanent Link: This blog entry brought to you by the procedure &quot;sp_MSForEachDB&quot;'>This blog entry brought to you by the procedure &quot;sp_MSForEachDB&quot;</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F04%2Fthe-power-of-n%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F04%2Fthe-power-of-n%2F" height="61" width="51" /></a></div><p>A peer the other day was having some trouble storing some some Chinese characters in a database.  Every time he would insert the data into his table, the results would look similar to the following.</p>
<p><a href="http://www.jasonstrate.com/images/ThePowerofN_345/image.png"><img style="display: inline; border: 0px;" title="image" src="http://www.jasonstrate.com/images/ThePowerofN_345/image_thumb.png" border="0" alt="image" width="179" height="45" /></a></p>
<p>The phrase he was adding was similar to the following:</p>
<blockquote><p>烟肉独角兽彩虹乳酪</p></blockquote>
<p>The T-SQL he was using was forwarded to me and it looked like the following:</p>
<pre class="brush: sql; ">
USE tempdb
GO

CREATE TABLE #AnotherLanguage
(Chinese nvarchar(50))
GO

INSERT INTO #AnotherLanguage
VALUES(&#039;烟肉独角兽彩虹乳酪&#039;)
GO

SELECT * FROM #AnotherLanguage
</pre>
<p>The title may have given a hint as to the issue he was facing.  To pass the string into the table as nvarchar it needs to be prefaced with the letter N.  One character with so much power.</p>
<p>See below…</p>
<pre class="brush: sql; ">
USE tempdb
GO

CREATE TABLE #AnotherLanguage
(Chinese nvarchar(50))
GO

INSERT INTO #AnotherLanguage
VALUES(N&#039;烟肉独角兽彩虹乳酪&#039;)
GO

SELECT * FROM #AnotherLanguage
</pre>
<p>This time the results are the following…</p>
<p><a href="http://www.jasonstrate.com/images/ThePowerofN_345/image_3.png"><img style="display: inline; border: 0px;" title="image" src="http://www.jasonstrate.com/images/ThePowerofN_345/image_thumb_3.png" border="0" alt="image" width="179" height="45" /></a></p>
<p>Not exactly an exciting issue, but a helpful one to recall none the less.  There was one other thing that needed to be done, that was a quick update to the installed languages.  This, though, didn’t seem to be an issue on my Windows 7 machine.</p>
<p><a href="http://www.jasonstrate.com/images/ThePowerofN_345/image001.png"><img style="display: inline; border: 0px;" title="image001" src="http://www.jasonstrate.com/images/ThePowerofN_345/image001_thumb.png" border="0" alt="image001" width="297" height="276" /></a></p>
<p>Hope this helps someone else.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2006/05/this-blog-entry-brought-to-you-by-the-procedure-sp_msforeachdb/' rel='bookmark' title='Permanent Link: This blog entry brought to you by the procedure &quot;sp_MSForEachDB&quot;'>This blog entry brought to you by the procedure &quot;sp_MSForEachDB&quot;</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/find-tables-with-forwarded-records/' rel='bookmark' title='Permanent Link: Find Tables with Forwarded Records'>Find Tables with Forwarded Records</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/04/the-power-of-n/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ABCs of CTEs at PASSMN</title>
		<link>http://www.jasonstrate.com/index.php/2010/03/abcs-of-ctes-at-passmn/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/03/abcs-of-ctes-at-passmn/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 21:45:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/03/abcs-of-ctes-at-passmn/</guid>
		<description><![CDATA[Last week I presented at the March Minnesota SQL Server User Group (PASSMN) meeting on using CTEs in SQL Server.  The session is meant as an overview and introduction to CTEs with some examples of their use and what some of the effects can be.
Overall the session was well received and I got the following [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/01/sql-saturday-32-abcs-of-ctes-deck/' rel='bookmark' title='Permanent Link: SQL Saturday 32 &#8212; ABCs of CTEs Deck'>SQL Saturday 32 &#8212; ABCs of CTEs Deck</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/march-passmn-meeting-03162010/' rel='bookmark' title='Permanent Link: March PASSMN Meeting (03/16/2010)'>March PASSMN Meeting (03/16/2010)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/march-passmn-meeting-tonight-03162010/' rel='bookmark' title='Permanent Link: March PASSMN Meeting Tonight (03/16/2010)'>March PASSMN Meeting Tonight (03/16/2010)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fabcs-of-ctes-at-passmn%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fabcs-of-ctes-at-passmn%2F" height="61" width="51" /></a></div><p><a title="IBM ABC Dino" href="http://www.flickr.com/photos/80868739@N00/3542641985/"><img style="margin: 0px 0px 10px; display: inline;" src="http://static.flickr.com/2464/3542641985_ddd828b9c2.jpg" border="0" alt="IBM ABC Dino" width="221" height="152" align="right" /></a>Last week I presented at the March Minnesota SQL Server User Group (PASSMN) meeting on using CTEs in SQL Server.  The session is meant as an overview and introduction to CTEs with some examples of their use and what some of the effects can be.</p>
<p>Overall the session was well received and I got the following scores:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="189"><strong>Area</strong></td>
<td width="89"><strong>Rating (1-5)</strong></td>
</tr>
<tr>
<td>Effectiveness of Demos</td>
<td>4.211</td>
</tr>
<tr>
<td>Usefulness of Materials</td>
<td>4.289</td>
</tr>
<tr>
<td>Presenter Skills</td>
<td>4.211</td>
</tr>
<tr>
<td>Blend of Demos</td>
<td>4.447</td>
</tr>
<tr>
<td>Overall presentation</td>
<td>4.289</td>
</tr>
</tbody>
</table>
<p>I had some pretty good comments from the attendees:</p>
<ul>
<li>Demos can be better organized</li>
<li>Good job</li>
<li>Great display of CTE uses</li>
<li>Great stuff &#8211; I can&#8217;t wait to start putting them to use</li>
<li>I found it to be a very interesting demonstration. My work still uses SQL 2000, but they&#8217;re looking to conver to 2008 later this year, so good.</li>
<li>Very informative</li>
</ul>
<p>And some that a little less than happy but still very useful for the next time I do this presentation:</p>
<ul>
<li>Seemed like too much time was spent on the surface repeating examples when we could have gone further in depth.</li>
<li>Add some useful examples for takeaway</li>
<li>Too much focus on simple example and not enough focus on complex useful examples</li>
<li>Lots to cover, a bit rushed due to time constraints</li>
</ul>
<p>For those that want to dig into some of the examples provided, <a href="http://www.jasonstrate.com/Presentations/ABCs of CTEs-201003.zip" target="_blank">here is the presentation for download</a>.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/01/sql-saturday-32-abcs-of-ctes-deck/' rel='bookmark' title='Permanent Link: SQL Saturday 32 &#8212; ABCs of CTEs Deck'>SQL Saturday 32 &#8212; ABCs of CTEs Deck</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/march-passmn-meeting-03162010/' rel='bookmark' title='Permanent Link: March PASSMN Meeting (03/16/2010)'>March PASSMN Meeting (03/16/2010)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/03/march-passmn-meeting-tonight-03162010/' rel='bookmark' title='Permanent Link: March PASSMN Meeting Tonight (03/16/2010)'>March PASSMN Meeting Tonight (03/16/2010)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/03/abcs-of-ctes-at-passmn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSWUG Spring &#8216;10 Ultimate Virtual Conference</title>
		<link>http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 15:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[Conference]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/</guid>
		<description><![CDATA[
The SSWUG Spring 2010 Virtual Conference is coming up.&#160; On April 7, 8, and 9, attend a conference from the comforts of your living room, office, or couch.&#160; And while you are at it you’ll get to sit on on some incredible presentations, interaction with speakers, chat with other attendees, make new contacts, lots of [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/check-out-the-ultimate-virtual-conference-from-sswug/' rel='bookmark' title='Permanent Link: Check out the Ultimate Virtual Conference from SSWUG'>Check out the Ultimate Virtual Conference from SSWUG</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/01/sswug-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Virtual Conference'>SSWUG Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fsswug-spring-10-ultimate-virtual-conference%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fsswug-spring-10-ultimate-virtual-conference%2F" height="61" width="51" /></a></div><p><a title="13_02_42" href="http://www.flickr.com/photos/54322086@N00/38811638/"><img style="display: inline; margin-left: 0px; margin-right: 0px" border="0" alt="13_02_42" align="right" src="http://static.flickr.com/31/38811638_013f5daa64.jpg" width="240" height="181" /></a></p>
<p>The <a href="http://www.sswug.org" target="_blank">SSWUG</a> Spring 2010 Virtual Conference is coming up.&#160; On April 7, 8, and 9, attend a conference from the comforts of your living room, office, or couch.&#160; And while you are at it you’ll get to sit on on some incredible presentations, interaction with speakers, chat with other attendees, make new contacts, lots of fun and surprises. </p>
<ul>
<li>More than <b>80 technical sessions</b></li>
<li>These are NOT sales presentations.</li>
<li>Live keynote presentations and interaction</li>
<li><b>On-Demand</b> access to sessions for <b>45 days</b> &#8211; miss a session? No problem.</li>
<li>Chat, Twitter Integration, SKYPE integration for Q&amp;A</li>
<li>Experience-based learning &#8211; find out what you need to know from people that are using the technology every day</li>
<li><b>6-Month SSWUG.ORG Membership</b> (or membership extension), included!</li>
<li>ALL-ACCESS Pass: SQL Server and Business Intelligence&#8230; SharePoint and .NET technologies &#8211; <b>all included</b>, one low price</li>
<li>Great <b>vendor hall</b> &#8211; learn about the best tools, technologies, publications and partners out there for your shop</li>
<li>Learning, learning and more learning</li>
</ul>
<p>If this sounds as awesome as it is, <a href="https://www.vconferenceonline.com/shows/spring10/uvc/register/multireg.asp?show=sql" target="_blank">register for the event here</a>.&#160; Among the presenters will be myself with the following topics:</p>
<blockquote><p><b>Using XML to Query Execution Plans</b></p>
<p>SQL Server stores its execution plans as XML in dynamic management views. The execution plans are a gold mine of information. From the whether or not the execution plan will rely on parallelism to what columns are requiring a key lookup after a non-clustered index seek. Through a the use of XML this information can be available at your finger tips to help determine the value and impact of an index and guide you in improving the performance of your SQL Server databases.</p>
<p><b>Prerequisites</b></p>
<ul>
<li>Understanding of basic T-SQL coding</li>
<li>Understanding of basic XQuery statements</li>
</ul>
<p><b>Goals:</b></p>
<ol>
<li>Discuss information available in an execution plan</li>
<li>Demonstrate use of XQuery to query execution cache</li>
<li>Demonstrate methods to performance tune</li>
</ol>
<p><b>Getting To Know Your Indexes</b></p>
<p>Without proper indexing SQL Server can be hard pressed to create efficient and performant execution plans. Dynamic Management Views (DMV) and system views provide a slew of information about indexes that can be used to analyze indexes within SQL Server. In this session we’ll go under the hood of SQL Server to look at DMVs and system views to know what indexes you have, should have, and how they feel about the way applications are treating them. </p>
<p><b>Prerequisites</b></p>
<ul>
<li>Understanding of performance tuning needs</li>
<li>Experience with Database design</li>
</ul>
<p><b>Goals:</b></p>
<ol>
<li>Identify methods to analyze current and potential indexes</li>
<li>Learn how to alleviate stress found on indexes</li>
<li>Demonstrate methods for tuning indexes</li>
</ol>
<p><b>A Function By Any Other Name Is A Function, Right? Right?!?</b></p>
<p>User defined functions provide a means to encapsulate business logic in the database tier. Often the purpose of the encapsulation is to provide standard method access segments of data within the database. Unfortunately, not all methods of creating user defined functions are equal. In this session we’ll review the types of user defined functions and investigate the performance impact in selecting the different types</p>
<p><b>Prerequisites</b></p>
<ul>
<li>Understanding of basic T-SQL </li>
</ul>
<p><b>Goals:</b></p>
<ol>
<li>Identify purposes for creating user defined functions</li>
<li>Discuss the types of user-defined functions</li>
<li>Demonstrate performance impact in selecting different types of functions</li>
</ol>
</blockquote>
<p>Stop in an check it out, there will be a lot of great sessions and great conversation.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/09/check-out-the-ultimate-virtual-conference-from-sswug/' rel='bookmark' title='Permanent Link: Check out the Ultimate Virtual Conference from SSWUG'>Check out the Ultimate Virtual Conference from SSWUG</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/01/sswug-virtual-conference/' rel='bookmark' title='Permanent Link: SSWUG Virtual Conference'>SSWUG Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/webcast-next-week-performance-impacts-related-to-different-function-types/' rel='bookmark' title='Permanent Link: Webcast Next Week &#8211; Performance Impacts Related to Different Function Types'>Webcast Next Week &#8211; Performance Impacts Related to Different Function Types</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/03/sswug-spring-10-ultimate-virtual-conference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
