<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sachin Rekhi's Ramblings : Database Refactoring</title><link>http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx</link><description>Tags: Database Refactoring</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Interesting Rename Refactoring Scenarios: Coalescing Two or More Objects</title><link>http://blogs.msdn.com/sachinre/archive/2006/10/04/Interesting-Rename-Refactoring-Scenarios_3A00_-Coalescing-Two-or-More-Objects.aspx</link><pubDate>Wed, 04 Oct 2006 05:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:788368</guid><dc:creator>SachinRe</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/788368.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=788368</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Here is another interesting use case for rename refactoring – coalescing two or more objects. What do I mean by that?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Well, this one is slightly different from what would traditionally be considered rename refactoring. It smells more like a semi-automated Merge Tables database refactoring.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Let’s say the scenario here is that you have a [dbo].[Contacts] table and a [dbo].[ContactPhotos] table. Both tables are keyed on ContactID. You may realize that you always end up joining these tables and thus wish to merge the ContactPhotos table with the Contacts table.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Let’s say the table definitions for these objects are as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CREATE TABLE &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[dbo].[Contacts]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ContactID &lt;SPAN style="COLOR: blue"&gt;int NOT NULL&lt;/SPAN&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;FirstName &lt;SPAN style="COLOR: blue"&gt;varchar&lt;/SPAN&gt;(100) &lt;SPAN style="COLOR: blue"&gt;NOT NULL&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MiddleName &lt;SPAN style="COLOR: blue"&gt;varchar&lt;/SPAN&gt;(100) &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;LastName &lt;SPAN style="COLOR: blue"&gt;varchar&lt;/SPAN&gt;(100) &lt;SPAN style="COLOR: blue"&gt;NOT NULL&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;BirthDate &lt;SPAN style="COLOR: blue"&gt;datetime NULL&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;SSN &lt;SPAN style="COLOR: blue"&gt;varchar&lt;/SPAN&gt;(50) &lt;SPAN style="COLOR: blue"&gt;NOT NULL&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CREATE TABLE &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[dbo].[ContactPhotos]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ContactID &lt;SPAN style="COLOR: blue"&gt;int NOT NULL&lt;/SPAN&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ContactPhoto &lt;SPAN style="COLOR: blue"&gt;image NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;To simplify this task, you can use rename refactoring to get you most of the way. Just follow these steps:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Copy the appropriate column definitions from the [dbo].[ContactPhotos] table to the [dbo].[Contacts] table. In our case, this is simply the [ContactPhoto] column.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Use Rename Refactoring to rename [dbo].[ContactPhotos] to [dbo].[Contacts]. You will be warned that the [dbo].[Contacts] object already exists. Simply say Yes to continue. You will then be shown a list of all the references that will be updated. The beauty of using rename refactoring in this way is that we automatically find all references to [Contact Photos] and update those references to now point to [Contacts].&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Delete the now un-needed old [dbo].[ContactPhotos] file from Solution Explorer.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Verdana&gt;Simplify queries. Clearly many queries will need to be updated to remove joins where they are now unnecessary. You can view the refactoring log file to see a list of all the places that the ContactPhotos table was referenced and review and update them if appropriate.&lt;/FONT&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;In upcoming CTP6 you will be able to leverage this feature exactly as described above. So check it out!&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:PersonName w:st="on"&gt;&lt;FONT face=Verdana&gt;Sachin Rekhi&lt;/FONT&gt;&lt;/st1:PersonName&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=788368" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category></item><item><title>Interesting Rename Refactoring Scenarios: Name Consistency</title><link>http://blogs.msdn.com/sachinre/archive/2006/10/04/Interesting-Rename-Refactoring-Scenarios_3A00_-Name-Consistency.aspx</link><pubDate>Wed, 04 Oct 2006 05:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:788360</guid><dc:creator>SachinRe</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/788360.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=788360</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;One of the primary uses of database rename refactoring is driving naming consistency of your schema objects around organizational standards.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;U&gt;&lt;FONT face=Verdana&gt;Naming Patterns&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;There are many kinds of object naming standards. You could, for example, have a standard that all primary key column names must be suffixed with ID. Or you may use naming conventions that specify all index names should be prefixed with IX_. This is often the case for FK, CHK, and many other constraints.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;U&gt;&lt;FONT face=Verdana&gt;Object Name Casing&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;In addition to actual naming patterns, it is often very useful for readability, consistency, and maintainability to have standards around casing of objects names. The scenario here is that you don’t want to change the actual object name, but simply the casing of the object name. You may not even want to change the object name casing, but simply standardize all references to that object name to use the same casing. The beauty of the rename refactoring facilities inside Team Edition for Database Professionals is that it allows you to do exactly that. You will see in the next CTP6 that you can accomplish this scenario by renaming an object to the same name but with different casing and it will update the object and all its references to use the exact same casing.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;U&gt;&lt;FONT face=Verdana&gt;Bracket Object Names&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;Similarly, databases tend to be inconsistent in their use of brackets around schema identifiers. Some organizations ideally would like to have object names always use brackets, for example, in a [MyTable] format. In addition, all references to the object should consistently reference the table according to the convention. Rename refactoring can be used to enforce this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana&gt;I hope that gave you an idea of some scenarios where rename refactoring is interesting for enforcing name consistency.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:PersonName w:st="on"&gt;&lt;FONT face=Verdana&gt;Sachin Rekhi&lt;/FONT&gt;&lt;/st1:PersonName&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=788360" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category></item><item><title>MSDN Webcast: Gert and Sachin on Database Testing and Refactoring</title><link>http://blogs.msdn.com/sachinre/archive/2006/08/09/MSDN-Webcast_3A00_-Gert-_2600_amp_3B00_-Sachin-on-Database-Testing-_2600_amp_3B00_-Refactoring.aspx</link><pubDate>Wed, 09 Aug 2006 06:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:692869</guid><dc:creator>SachinRe</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/692869.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=692869</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Gert Drapers, Development Manager, and I did a MSDN webcast yesterday on Database Testing &amp;amp; Refactoring using Team Edition for Database Professionals. This is the third part of a four-part series on Team Edition for Database Professionals. I would encourage you to check it out! You can see me walking through exactly how you can immediately put these features to use in your own environment.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;You can find a link to the On Demand webcast here:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/events/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&amp;amp;Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032304011%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%5e" mce_href="http://www.microsoft.com/events/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&amp;amp;Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032304011%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%5e"&gt;&lt;FONT face=Verdana size=2&gt;MSDN Webcast: Visual Studio 2005 Team Edition for Database Professionals (Part 3 of 4): Database Testing and Refactoring (Level 200)&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;And you can also find a link to the entire series here:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/events/series/msdnvsts2005.mspx" mce_href="http://www.microsoft.com/events/series/msdnvsts2005.mspx"&gt;&lt;FONT face=Verdana size=2&gt;Visual Studio 2005 Team System: Power in Simplicity&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:PersonName w:st="on"&gt;&lt;FONT face=Verdana size=2&gt;Sachin Rekhi&lt;/FONT&gt;&lt;/st1:PersonName&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=692869" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Unit+Testing/default.aspx">Database Unit Testing</category><category domain="http://blogs.msdn.com/sachinre/archive/tags/Videos/default.aspx">Videos</category></item><item><title>Best Practice: Deploying Database Rename Refactorings</title><link>http://blogs.msdn.com/sachinre/archive/2006/07/26/Best-Practice_3A00_-Deploying-Database-Rename-Refactorings.aspx</link><pubDate>Wed, 26 Jul 2006 04:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:678444</guid><dc:creator>SachinRe</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/678444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=678444</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Team Edition for Database Professionals is targeted primarily at managing iterative changes for preproduction database development.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;The primary use case for deploying rename refactorings is to your local sandbox server. The cleanest way to setup this sandbox server is to always drop and re-create the database at each deployment. Data can be regenerated for testing purposes using the data generation tool.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Sometimes, however, you will want to update an existing database and the data must be maintained. Team Data’s deployment feature does not automatically generate a build script to perform the associated data motion for you. However, this task can be accomplished through the following suggested process. The default build options result in the build script containing an add of the new table or column whenever you do a rename refactor. The default build script does not drop the old table or column. This provides you the opportunity to follow the following process to &lt;B style="mso-bidi-font-weight: normal"&gt;manually perform data&lt;/B&gt; &lt;B style="mso-bidi-font-weight: normal"&gt;motion&lt;/B&gt; using Team Edition for Database Professionals:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Perform a rename refactoring operation&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Right-click on the object name in Schema View and select Refactor -&amp;gt; Rename…&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Build the database project&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Right-click on the database project and select Build&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Deploy the database project&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Right-click on the database project and select Deploy&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Perform data motion of data from old table\column to new table\column&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Table&lt;/I&gt;: INSERT INTO &amp;lt;new_table&amp;gt; (columns) SELECT (columns) FROM &amp;lt;old_table&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Column&lt;/I&gt;: UPDATE &amp;lt;table&amp;gt; SET &amp;lt;new_column&amp;gt; = &amp;lt;old_column&amp;gt; FROM &amp;lt;table&amp;gt; WHERE &amp;lt;pk_column&amp;gt; = &amp;lt;pk_column&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;5.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Drop the old table\column&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Table&lt;/I&gt;: DROP TABLE &amp;lt;old_table&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 35pt; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1; tab-stops: list 35.0pt"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Column&lt;/I&gt;: ALTER TABLE &amp;lt;table&amp;gt; DROP COLUMN &amp;lt;old_column&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Alternatively, you can avoid performing the data motion manually by finding all adds of the new table\column in the build script and &lt;B style="mso-bidi-font-weight: normal"&gt;converting them into sp_rename calls&lt;/B&gt;. The process for this would look like the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Perform a rename refactoring operation&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo3; tab-stops: list .5in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Right-click on the object name in Schema View and select Refactor -&amp;gt; Rename…&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Build the database project&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Right-click on the database project and select Build&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Modify the build script to replace add table\columns with sp_rename calls&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Table&lt;/I&gt;: sp_rename ‘&amp;lt;old_table&amp;gt;’, ‘&amp;lt;new_table&amp;gt;’, ‘OBJECT’&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Column&lt;/I&gt;: sp_rename ‘&amp;lt;table&amp;gt;.&amp;lt;old_column&amp;gt;’, ‘&amp;lt;new_column&amp;gt;’, ‘COLUMN’&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Verdana size=2&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana size=2&gt;Execute the build script&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT face=Verdana size=2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; tab-stops: list 0in"&gt;Let me know your thoughts on this guidance. Do you prefer one approach to the other? Would you do it another way?&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list .25in"&gt;&lt;FONT face=Verdana size=2&gt;Sachin Rekhi&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=678444" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category></item><item><title>Book Recommendation: Refactoring Databases</title><link>http://blogs.msdn.com/sachinre/archive/2006/07/01/Book-Recommendation_3A00_-Refactoring-Databases.aspx</link><pubDate>Sat, 01 Jul 2006 21:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653692</guid><dc:creator>SachinRe</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/653692.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=653692</wfw:commentRss><description>&lt;P&gt;I wanted to send kudos over to Scott W. Ambler and Pramodkumar J. Sadalage for recently publishing a great book on the very topic of refactoring databases.&lt;/P&gt;
&lt;P&gt;Refactoring Databases: Evolutionary Database Design&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amazon.com/gp/product/0321293533/104-1114081-9071168?v=glance&amp;amp;n=283155"&gt;http://www.amazon.com/gp/product/0321293533/104-1114081-9071168?v=glance&amp;amp;n=283155&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I'm a big fan of this book. You'll even find me saying so in the book's foreword :) Scott and Pramod have put together an authoritative source on refactoring databases much in the same style as Martin Fowler's original refactoring book. The book educates you on exactly what is database refactoring and a process for actually going about it. Most importantly, it provides an in-depth catalog of many different database refactorings, describing in detail exactly how to execute on them. Prior to this book, database refactoring was often just an academic exericse. But I hope now people will start to adopt this technique as a highly productive aspect of their agile database development.&lt;/P&gt;
&lt;P&gt;And once again, Team Edition for Database Professionals hopes to help you realize the power of this technique by offering automated tooling around database refactoring.&lt;/P&gt;
&lt;P&gt;Sachin Rekhi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=653692" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category></item><item><title>What is database refactoring?</title><link>http://blogs.msdn.com/sachinre/archive/2006/07/01/What-is-database-refactoring_3F00_.aspx</link><pubDate>Sat, 01 Jul 2006 20:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:653678</guid><dc:creator>SachinRe</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/sachinre/comments/653678.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sachinre/commentrss.aspx?PostID=653678</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Well, I’m glad you asked :) The best way to explain database refactoring is to offer two different perspectives, depending on the background you are coming from. I offer a view on database refactoring both from the perspective of a seasoned application developer and a traditional database professional.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;U&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;Application Developer View&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;For most application developers, the concept of refactoring is not new. Most of the mainstream IDEs, including Visual Studio, have built-in support for automated refactoring. A refactoring is often defined as &lt;SPAN style="mso-bidi-font-weight: bold"&gt;“a small change to your code which improves its design without changing its semantics.” The whole idea around refactoring is to make small incremental improvements to the design of your application in an iterative and agile way. For the more academic sort, you’ve probably read &lt;A href="http://www.amazon.com/gp/product/0201485672/104-1114081-9071168?n=283155" mce_href="http://www.amazon.com/gp/product/0201485672/104-1114081-9071168?n=283155"&gt;Martin Fowler’s Refactoring book&lt;/A&gt;. The kinds of refactorings you are probably used to are rename refactorings, where you rename a symbol name and all of its references, and extract method, where you take a fragment of a method and separate it out into a reusable method of its own.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;Database refactoring is merely extending this concept of refactoring from the application code to your database code. Much in the same way, you can imagine a database rename refactoring would rename a database object and all of its references in the database. Similarly, an extract stored procedure refactoring would pull out a SQL fragment from a stored procedure and place it in its own reusable procedure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;Team Edition for Database Professionals is the first tool to try to bring the same refactoring experience that you have always enjoyed for application development to the data world. We have started this effort with initial support for database rename refactoring fully automated inside the toolset.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;U&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;Database Professional View&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;The term refactoring likely means nothing to you. However, let me translate. Let’s take for example database rename refactoring. Terms that we found resonated better with DBAs and DB Devs was the idea of “cascading changes”. Let’s say for example you wanted to rename the Customers table. If you were to perform a rename refactoring on the table, you would rename the table and all the references to the table in views, stored procedures, functions, etc. What a database rename refactoring tool does is find all the references and &lt;I style="mso-bidi-font-style: normal"&gt;automate the cascading of these changes for you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;To many database professionals, cascading changes as described above is quite a risky endeavor and often simply avoided. The whole hope with such automated tooling is that managing such changes moves from a fear-inspiring task to one which you can do with confidence.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;But now I’m sure you can imagine additional database refactorings. For example, a change type refactoring would allow you to change, say, a column's data type, and it would appropriately change all associated&amp;nbsp;object data&amp;nbsp;types (of foreign keys, of variable assignments of the column, etc). In the future I’m sure we’ll see automated support for many other kinds of database refactorings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;&lt;FONT face=Verdana size=2&gt;I hope that helped to give you a couple of perspectives on just what is database refactoring. In future posts I’ll be sharing exactly how to leverage Team Edition for Database Professionals to perform a rename refactoring and how to do it safely with confidence.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Verdana size=2&gt;Sachin Rekhi&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=653678" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sachinre/archive/tags/Database+Refactoring/default.aspx">Database Refactoring</category></item></channel></rss>