<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.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>Buck Woody : Design, Developer, SQL Server</title><link>http://sqlblog.com/blogs/buck_woody/archive/tags/Design/Developer/SQL+Server/default.aspx</link><description>Tags: Design, Developer, SQL Server</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>SQL Azure Use Case: Shared Storage Application</title><link>http://sqlblog.com/blogs/buck_woody/archive/2011/04/26/sql-azure-use-case-shared-storage-application.aspx</link><pubDate>Tue, 26 Apr 2011 13:33:50 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35207</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/35207.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=35207</wfw:commentRss><description>&lt;p&gt;&lt;span style="font-size:x-small;"&gt;&lt;em&gt;&lt;span style="font-size:small;"&gt;This is one in a series of posts on when and where to use a distributed architecture design in your organization's computing needs. You can find the main post here: &lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/buckwoody/archive/2011/01/18/windows-azure-and-sql-azure-use-cases.aspx"&gt;&lt;span style="font-size:small;"&gt;&lt;u&gt;&lt;font color="#800080"&gt;http://blogs.msdn.com/b/buckwoody/archive/2011/01/18/windows-azure-and-sql-azure-use-cases.aspx&lt;/font&gt;&lt;/u&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:small;"&gt; &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style="font-size:small;"&gt;Description:&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size:small;"&gt;On-premise data will be a part of computing for quite some time – perhaps permanently. Bandwidth requirements, security, or even financial considerations for large data sets often dictate that relational (on non-relational) systems will be maintained locally in many organizations, especially in enterprise computing. &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size:small;"&gt;But distributed data systems are useful in many situations. Organizations may wish to store a portion of data off-site, either for sharing the data with other applications (including web-based applications) or as a supplement to a High-Availability and Disaster Recovery (HADR) strategy.&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:small;"&gt;   &lt;p&gt;&lt;strong&gt;&lt;span style="font-size:small;"&gt;Implementation:&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;SQL Azure can be used to add an additional option to an HADR strategy by copying off portions (or all) of an on-premise database system.&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-79-79-metablogapi/3386.sql_2D00_aHADR_5F00_2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="sql-aHADR" border="0" alt="sql-aHADR" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-79-79-metablogapi/4265.sql_2D00_aHADR_5F00_thumb.png" width="298" height="181" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;In this arrangement, on-premise systems remain as they are. Data is replicated using many technologies, such as SQL Server Integration Services (SSIS), scripts, or Microsoft’s Sync Framework to a SQL Azure database. This data can be kept “cold”, meaning that a manual process is required to bring the data back, or as a “warm” standby using connection string management in the application.&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;Recently we architected a solution where a company kept a rolling two-week window of data replicated to SQL Azure using the &lt;a href="http://msdn.microsoft.com/en-us/sync/default.aspx" target="_blank"&gt;Sync Framework&lt;/a&gt;. The application, a compiled EXE running on user’s systems, had a “switch connections” button, that allowed the users to take a laptop to another location, select that option, and continue working from anywhere they had Internet connectivity. This required forethought and planning, and did not replace their primary HADR systems, but it did allow them to continue operations in the case of a severe outage at multiple sites. Since they are an emergency services provider, this gave them the highest redundancy.&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;Another option is to amalgamate data from disparate sources. &lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-79-79-metablogapi/6320.sql_2D00_aHyb_5F00_2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="sql-aHyb" border="0" alt="sql-aHyb" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-79-79-metablogapi/2625.sql_2D00_aHyb_5F00_thumb.png" width="342" height="134" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;In this arrangement, two or more data services (one of which is SQL Azure) are accessed by a single program. The program queries each system independently, and using LINQ a single query can work across all of the data, assuming there is some sort of natural or artificial “key” that can join the data sets together. The user programs simply view this single data set as a single data source, unaware of the underlying data sets. This allows great flexibility and agility in the downstream program. The upstream data sources can change as long as the elements are kept consistent.&lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style="font-size:small;"&gt;There are performance and security implications to amalgamated data systems, but if architected carefully they provide multiple benefits. A few of of these are that other systems can access the individual data sources, reporting is simplified and standardized, and multiple copies of data are eliminated.&lt;/span&gt;&lt;/p&gt;   &lt;span style="font-size:small;"&gt;     &lt;p&gt;&lt;strong&gt;&lt;span style="font-size:small;"&gt;Resources:&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;      &lt;p&gt;&lt;span style="font-size:small;"&gt;You can read more about the Sync Framework and SQL Azure here: &lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/sync-framework-sql-server-to-sql-azure-synchronization.aspx"&gt;http://social.technet.microsoft.com/wiki/contents/articles/sync-framework-sql-server-to-sql-azure-synchronization.aspx&lt;/a&gt;&amp;#160;&lt;/span&gt;&lt;/p&gt;      &lt;p&gt;&lt;span style="font-size:small;"&gt;If you are new to LINQ, you can find more resources on it here: &lt;a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb308959.aspx&lt;/a&gt;&amp;#160;&lt;/span&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/span&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=35207" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Azure/default.aspx">Azure</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Cloud/default.aspx">Cloud</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Cloud+Computing/default.aspx">Cloud Computing</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Concepts/default.aspx">Concepts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Data/default.aspx">Data</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Data+Professional/default.aspx">Data Professional</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Disaster+Recovery/default.aspx">Disaster Recovery</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Learning+Plan/default.aspx">Learning Plan</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Platform+Independence/default.aspx">Platform Independence</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Azure/default.aspx">SQL Azure</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSIS/default.aspx">SSIS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Windows+Azure/default.aspx">Windows Azure</category></item><item><title>More Tables or More Databases?</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/05/19/more-tables-or-more-databases.aspx</link><pubDate>Wed, 19 May 2010 11:37:22 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:25285</guid><dc:creator>BuckWoody</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/25285.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=25285</wfw:commentRss><description>&lt;p&gt;I got an e-mail from someone that has an interesting situation. He has 15,000 customers, and he asks if he should have a database for their data per customer. Without a LOT more data it’s impossible to say, of course, but there &lt;em&gt;are&lt;/em&gt; some general concepts to keep in mind.&lt;/p&gt;  &lt;p&gt;Whenever you’re segmenting data, it’s all about boundary choices. You have not only boundaries around how big the data will get, but things like how many objects (tables, stored procedures and so on) that will be involved, if there are any cross-sections of data (do they share location or product information) and – very important – what are the security requirements?&lt;/p&gt;  &lt;p&gt;From the answer to these types of questions, you now have the choice of making multiple tables in a single database, or using multiple databases. A database carries some overhead – it needs a certain amount of memory for locking and so on. But it has a very clean boundary – everything from objects to security can be kept apart. Having multiple users in the same database is possible as well, using things like a Schema. But keeping 15,000 schemas can be challenging as well.&lt;/p&gt;  &lt;p&gt;My recommendation in complex situations like this is similar to a post on decisions that I did earlier – I lay out the choices on a spreadsheet in rows, and then my requirements at the top in the columns. I&amp;#160; give each choice a number based on how well it meets each requirement. At the end, the highest number wins.&lt;/p&gt;  &lt;p&gt;And many times it’s a mix – perhaps this person could segment customers into larger regions or districts or products, in a database. Within that database might be multiple schemas for the customers. Of course, he needs to query across all customers, that becomes another requirement.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=25285" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Use Those Schemas, People!</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/05/18/use-those-schemas-people.aspx</link><pubDate>Tue, 18 May 2010 12:39:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:25246</guid><dc:creator>BuckWoody</dc:creator><slash:comments>6</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/25246.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=25246</wfw:commentRss><description>&lt;p&gt;Database Schemas are just containers – they aren’t users or anything else – think of a sub-directory on the hard drive. In early versions of SQL Server we “hid” schemas, placing all objects under “dbo”, which gave the erroneous perception that Schemas are users. &lt;/p&gt;  &lt;p&gt;In SQL Server 2005, we “un-hid” or re-introduced schemas within the database. Users can have a default schema (a place where their new objects go), you can add new schemas and transfer objects between them, and they have many other benefits.&lt;/p&gt;  &lt;p&gt;But I still see a lot of applications, developed by shops I know as well as vendors, that don’t make use of a Schema. Everything is piled under dbo. I completely understand this – since permissions can be granted to a schema, they feel a lot like a user, so it’s just easier not to worry about both users and schemas when you create a database. But if you’ll use them properly you can make your application more understandable and portable.&lt;/p&gt;  &lt;p&gt;You should at least take a few minutes and read more about them – you owe it to your users: &lt;a href="http://msdn.microsoft.com/en-us/library/ms190387.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms190387.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=25246" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Best+Practices/default.aspx">Best Practices</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Using linked servers, OPENROWSET and OPENQUERY</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/03/16/using-linked-servers-openrowset-and-openquery.aspx</link><pubDate>Tue, 16 Mar 2010 12:41:33 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:23448</guid><dc:creator>BuckWoody</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/23448.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=23448</wfw:commentRss><description>&lt;p&gt;SQL Server has a few mechanisms to reach out to another server (even another server type) and query data from within a Transact-SQL statement. Among them are a set of stored credentials and information (called a &lt;a href="http://msdn.microsoft.com/en-us/library/ms190479.aspx" target="_blank"&gt;Linked Server&lt;/a&gt;), a statement that uses a linked server called called &lt;a href="http://msdn.microsoft.com/en-us/library/ms188427.aspx" target="_blank"&gt;OPENQUERY&lt;/a&gt;, another called &lt;a href="http://msdn.microsoft.com/en-us/library/ms190312.aspx" target="_blank"&gt;OPENROWSET&lt;/a&gt;, and one called &lt;a href="http://msdn.microsoft.com/en-us/library/ms179856.aspx" target="_blank"&gt;OPENDATASOURCE&lt;/a&gt;. This post isn’t about those particular functions or statements – hit the links for more if you’re new to those topics.&lt;/p&gt;  &lt;p&gt;I’m actually more concerned about where I see these used than the particular method. In many cases, a Linked server isn’t another Relational Database Management System (RDMBS) like Oracle or DB2 (which is possible with a linked server), but another SQL Server. My concern is that linked servers are the new Data Transformation Services (DTS) from SQL Server 2000 – something that was designed for one purpose but which is being morphed into something much more.&lt;/p&gt;  &lt;p&gt;In the case of DTS, most of us turned that feature into a full-fledged job system. What was designed as a simple data import and export system has been pressed into service doing logic, routing and timing. And of course we all know how painful it was to move off of a complex DTS system onto SQL Server Integration Services.&lt;/p&gt;  &lt;p&gt;In the case of linked servers, what should be used as a method of running a simple query or two on another server where you have occasional connection or need a quick import of a small data set is morphing into a full federation strategy. In some cases I’ve seen a complex web of linked servers, and when credentials, names or anything else changes there are huge problems.&lt;/p&gt;  &lt;p&gt;Now don’t get me wrong – linked servers and &lt;a href="http://msdn.microsoft.com/en-us/library/ms188721.aspx" target="_blank"&gt;other forms of distributing queries&lt;/a&gt; is a fantastic set of tools that we have to move data around. I’m just saying that when you start having lots of workarounds and when things get really complicated, you might want to step back a little and ask if there’s a better way. Are you able to tolerate some latency? Perhaps you’re &lt;a href="http://msdn.microsoft.com/en-us/library/ms345108(SQL.90).aspx" target="_blank"&gt;able to use Service Broker&lt;/a&gt;. Would you like to be platform-independent on the data source? &lt;a href="http://www.c-sharpcorner.com/UploadFile/mikegriffin/middle_tier12232005054629AM/middle_tier.aspx" target="_blank"&gt;Perhaps a middle-tier might make more sense&lt;/a&gt;, abstracting the queries there and sending them to the proper server. Designed properly, I’ve seen these systems scale further and be more resilient than loading up on linked servers.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=23448" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Planning/default.aspx">Planning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category></item><item><title>It’s OK to take a Shortcut Sometimes</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/03/08/it-s-ok-to-take-a-shortcut-sometimes.aspx</link><pubDate>Mon, 08 Mar 2010 14:06:12 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22949</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/22949.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=22949</wfw:commentRss><description>&lt;p&gt;I was working this weekend with a fairly simple Excel spreadsheet, and I had to decompose one cell in it out to three columns in a SQL Server table. There are tools within SQL Server Integration Services (SSIS) that should be able to do that, but I just couldn’t find my way around them properly.&lt;/p&gt;  &lt;p&gt;I’m not as familiar with SSIS as I would like to be – it’s just not my day-to-day tool. I was struggling with the split of the cells, since it had several different types and kinds of delimeters for the data. I knew how to do it with regular expressions, I knew how to do it with Transact-SQL, I knew how to do it with lots of programs, but I just couldn’t figure it out in SSIS. I’m sure that’s my fault – not the fault of the tool, by the way.&lt;/p&gt;  &lt;p&gt;I spoke with the person that created the spreadsheet, and it turns out that he had combined those fields from his source to begin with!&amp;#160; In other words, he could split them out for me. What a relief!&amp;#160; Yes, I need to come back some time and figure out how to beat this, but right now I just needed to get the work done. He split the cells out for me in the spreadsheet (took him about 3 minutes) and then I had the three discreet cells I was looking for.&lt;/p&gt;  &lt;p&gt;Sometimes it’s OK to take a shortcut. As long as you think it through, you can safely do things the “easy way”, when you’re careful and understand what the ramifications are. The key here is that this was a one-time import, I understood both sides of the data, and had done my research. The data itself didn’t change; just it’s cell location. And that was all OK.&lt;/p&gt;  &lt;p&gt;So don’t make it harder on yourself than it needs to be. Consider the alternatives – and take the help where you safely can.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22949" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Code that Writes Code - A Good Idea or Not?</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/02/16/code-that-writes-code-a-good-idea-or-not.aspx</link><pubDate>Tue, 16 Feb 2010 14:14:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22348</guid><dc:creator>BuckWoody</dc:creator><slash:comments>4</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/22348.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=22348</wfw:commentRss><description>&lt;P&gt;I’m a big fan of code that writes code&amp;nbsp;– most of the time. For instance, whenever you use the “templates” feature in SQL Server Management Studio (SSMS) or the Maintenance Wizard, you’re using code that writes other code. There’s even a trick of writing Transact-SQL (T-SQL) code that in turn creates other code.&lt;/P&gt;
&lt;P&gt;But there is a class of code that writes code that I’m more cautious about. Whenever a program “automatically” generates a database schema, I begin to get nervous. No, I’m not talking about Entity Relationship Diagram (ERD) tools such as those from Quest and Embarcadero, I’m talking about things like NHibernate and other coding paradigms that “abstract” the database layer away from the developer. &lt;/P&gt;
&lt;P&gt;I have two&amp;nbsp;reasons that&amp;nbsp;I’m not impressed with these&amp;nbsp;programs and paradigms. &lt;/P&gt;
&lt;P&gt;First, they do not take the entire solution into account. As data professionals we learn our platform (whether that’s XML, flat files, SQL Server, Oracle, IBM, whatever) and we study how each of the features maps to a complete solution. I might choose to use Replication, Service Broker, Clustering, FileStream, or any number of features to completely remove the need for code in that area. And by making those choices,&lt;EM&gt; I change the design of the database accordingly, based on the&lt;/EM&gt; &lt;EM&gt;solution&lt;/EM&gt;. The abstraction tools don’t&amp;nbsp;– they just spit out the same Data Definition Language (DDL) statements they know how to create, without thinking about maintenance, speed, reliability or anything else. &lt;/P&gt;
&lt;P&gt;When I mention this to the developer, they say “just put that in later”&amp;nbsp;– and that’s the beginning of woes for the data professional. Most of the time you &lt;EM&gt;can’t&lt;/EM&gt; put things of a fundamental nature in later. In some cases, it’s a complete tear-down and re-write of the entire database. Very painful, and something you never want to experience.&lt;/P&gt;
&lt;P&gt;The second main reason that I am skeptical about tools that automatically create DDL statements to create databases is that they don’t do a good job. Once again, this is because of a holistic view&amp;nbsp;– the tool doesn’t have the capability to take everything into account, including the data pattern, so it has no idea how far to normalize, where to put files and filegroups, what kind (if any) indexes are needed, or when to choose between a natural or surrogate key. &lt;/P&gt;
&lt;P&gt;Is all this just because I’m a DBA, and anal about my databases? No. It’s a &lt;STRONG&gt;business&lt;/STRONG&gt; problem, because these tools continue to separate the DBA from the Developer, and both from the Business Analyst. And it's the business that suffers when developers (or DBA’s) take shortcuts. I wonder how much time and money are wasted in business re-writing databases because&amp;nbsp;of a&amp;nbsp;shortcut using poor tools?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So let’s do the hard work&amp;nbsp;– let’s let the business requirements dictate the solution, rather than the other way around. Even for the “little” databases, which of course never stay that way.&lt;/P&gt;
&lt;P&gt;Now, does this mean I hate NHibernate or the Entity Framework? Not at all!&amp;nbsp; Just work &lt;EM&gt;with&lt;/EM&gt; your data professionals instead of &lt;EM&gt;without &lt;/EM&gt;them. You’ll find that by bringing the best practices of these ORM tools together with a well-designed database, you’ll deliver a solution to the business that is fast, reliable and safe. Isn’t that what we all want?&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22348" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Rant/default.aspx">Rant</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Data Design</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/02/02/data-design.aspx</link><pubDate>Tue, 02 Feb 2010 14:31:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:21711</guid><dc:creator>BuckWoody</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/21711.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=21711</wfw:commentRss><description>&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;I give series of classes and presentations on Data Design. I say “data” design instead of “database” design because we should consider more than just the database. Data might actually be stored in non-relational stores, such as Excel or XML files, and it might also be located in remote data stores like “cloud” technologies. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Here are the links I use in that presentation. Although this isn't a comprehensive list of Data Design topics, I’ll visit this topic from time to time so you may want to bookmark this page in your favorites:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Evidence and Comments:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;A href="http://tinyurl.com/ygvbadc"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ygvbadc&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;A href="http://tinyurl.com/ydeh9ut"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ydeh9ut&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;A href="http://tinyurl.com/ycu9apq"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ycu9apq&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;A href="http://tinyurl.com/ya7a9xc"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ya7a9xc&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;A href="http://tinyurl.com/ydlumyp"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ydlumyp&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; &lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Importance:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Yes, it matters: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yb5ucvn"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yb5ucvn&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Classic software development mistakes: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/y9x9vn8"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/y9x9vn8&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Necessity of Good Design: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yac3um3"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yac3um3&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Importance of Database Design Ranked high for BA/Dev interaction: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yex4sjf"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yex4sjf&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Structured Methods:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Test-Driven Development: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/maus78"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/maus78&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;From the BA’s Perspective: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yea6pbe"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yea6pbe&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Data-Map Examples: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/2d2nhr"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/2d2nhr&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Universal Patterns for Data Modelling: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/ybj7tb3"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/ybj7tb3&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Tools:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;EF Framework Design Example: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yeuda49"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yeuda49&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language:EN-GB;"&gt;&lt;FONT size=3 face=Calibri&gt;Using EF and LINQ can cause divisions: &lt;/FONT&gt;&lt;A href="http://tinyurl.com/yaljmhn"&gt;&lt;FONT color=#0000ff size=3 face="Times New Roman"&gt;http://tinyurl.com/yaljmhn&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=21711" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Links/default.aspx">Links</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Tools and Processes for “Fitting it all in”</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/01/18/tools-and-processes-for-fitting-it-all-in.aspx</link><pubDate>Mon, 18 Jan 2010 14:42:05 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:21147</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/21147.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=21147</wfw:commentRss><description>&lt;p&gt;Most data professionals I’ve met work in two modes: we plan for our day, and we react to the situations around us. I’m staring at my list of things that I need to do today right now, which is my planned work. Of course, I have no idea how much of that will really get done – it’s optimistic to be sure. On the other hand I have several systems I manage, and at any moment one of them or the people that interface with them may “change state” such that I need to give them some attention.&lt;/p&gt;  &lt;p&gt;So how do I meld the two? Sometimes it can be quite difficult. I’m constantly working through my list in my mind, re-arranging what I’m focusing on based on what I perceive as the highest need. There are, however, some tools that I use each day to help me manage the workflow.&lt;/p&gt;  &lt;p&gt;I use Outlook for tracking everything, since it has a task list (my primary tracking), a calendar, mail and so on. Also I can share the information, it’s on-line so I can see it anywhere, and I can even take it offline onto the plane this week when I fly out of town. &lt;/p&gt;  &lt;p&gt;For the “ad-hoc” work, I rely on a script library, which I keep as SQL Server Management Studio projects. I keep those scripts and projects backed using Microsoft Live Mesh, which synchronizes those files (along with a few other critical files and my IE Favorites) across not only my laptop and primary systems, but even with my Virtual Machines. &lt;/p&gt;  &lt;p&gt;Also for my SQL Server systems I use the Standard Reports I’ve blogged about here. I also use Greg Larsen’s Database Dashboard, and a series of PowerShell scripts that work across my systems, alerting me to any problems. Of course I’m using SQL Server Agent Jobs quite a bit, and I also use Alerts and some Perfmon automation for my monthly baselining.&lt;/p&gt;  &lt;p&gt;So – is this your experience as well? Do you get driven by both planned and unplanned work? What tools and processes do you use to keep it all straight with your SQL Server Instances?&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=21147" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Agent/default.aspx">Agent</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Management/default.aspx">Management</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Planning/default.aspx">Planning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Process/default.aspx">Process</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+Management+Studio/default.aspx">SQL Server Management Studio</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSMS/default.aspx">SSMS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item><item><title>Know Your Product Specifications</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/01/13/know-your-product-specifications.aspx</link><pubDate>Wed, 13 Jan 2010 14:57:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:21010</guid><dc:creator>BuckWoody</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/21010.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=21010</wfw:commentRss><description>&lt;p&gt;As the Data Professional in your organization, the rest of the org looks to you to ensure that the system can handle what the business requires. To do that, you need to know two things: what the business requires, and what SQL Server can do.&lt;/p&gt;  &lt;p&gt;But of course there’s a bit more to it than that. Knowing the business side of the requirements – well, I teach an entire course on that. But knowing what SQL Server can do is something you can find out on your own.&lt;/p&gt;  &lt;p&gt;SQL Server comes in &lt;em&gt;versions&lt;/em&gt;, which are released based on date, and &lt;em&gt;editions&lt;/em&gt;, which are based on features and capabilities. It’s that last part that I want to focus on today.&lt;/p&gt;  &lt;p&gt;As Microsoft SQL Server matures, you’re going to see even more separation between what each edition of SQL Server can do and where it should be used. In the past, most folks have only focused on three editions – Express (the “free” one), Standard, and Enterprise. The rule of thumb was that if Standard was good enough at the moment, put it in. And it is true (and a good thing) that you can upgrade from one edition to another fairly easily.&lt;/p&gt;  &lt;p&gt;But as time goes on, we should spend a little more time understanding what each edition does, what it’s features and capabilities are, and where and when we should put them in. As I study this information, I’ll throw in my 2 cents and you can as well based on what you see. One thing I’ve found so far is that once I have the business requirements, there’s a mix of what I can write in code and what might already be included in a different edition. It’s important to look long and hard at that choice – writing a feature on my own is certainly cheaper in the short term than moving to a “higher” edition, but in some cases it makes sense to let Microsoft handle that lifting.&lt;/p&gt;  &lt;p&gt;These links are ones that you should bookmark and take a peek at periodically. They are the “header” links for more information on those features and capabilities:&lt;/p&gt;  &lt;p&gt;SQL Server 2008: &lt;a href="http://msdn.microsoft.com/en-us/library/ms143287.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms143287.aspx&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;SQL Server 2008 R2: &lt;a href="http://msdn.microsoft.com/en-us/library/ms143287(SQL.105).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms143287(SQL.105).aspx&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In addition, you might start learning a little more about SQL Azure. I’ll talk more about that later.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=21010" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Career/default.aspx">Career</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Link+Lists/default.aspx">Link Lists</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft+Update/default.aspx">Microsoft Update</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Planning/default.aspx">Planning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Azure/default.aspx">SQL Azure</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>It’s Data Tier Application and Data Application Component</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/12/23/it-s-data-tier-application-and-data-application-component.aspx</link><pubDate>Wed, 23 Dec 2009 15:52:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:20206</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/20206.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=20206</wfw:commentRss><description>&lt;p&gt;OK – In SQL Server 2008 R2 we did “re-use” an acronym or two (DAC and DTA), but it’s important to remember there are actually two parts to this new feature. One is the Data Application Component (DAC) and the other is the Data Tier Application (DTA). The DAC is the file created for a DTA.&lt;/p&gt;  &lt;p&gt;In SQL Server 2008R2 and Visual Studio you’ll find there is a new way to write and transfer database code. I’ll blog about it more as I finish my testing, but the process works kind of like this… &lt;/p&gt;  &lt;p&gt;You can “birth” a Data Tier Application in two places. You can create a new project type in Visual Studio where the developer can create the database structure, put all of the policies that they want to enforce and so on there. The DBA can also right-click a database and make a Data Tier Application out of a current structure. &lt;/p&gt;  &lt;p&gt;In both cases, something called a DAC – or Data Application Component – is created. It’s a file with the payload of the the major parts of the structure of the database and so on. that’s the “package” you use to transfer the DTA around.&lt;/p&gt;  &lt;p&gt;From there, you right-click in the “Data Tier Application” node in SQL Server Management Studio on another Instance and “Deploy” the Data Tier Application. It will build the database for you and keep it together as a DTA. You can make changes in the “originating” system or code, and then “upgrade” the Data Tier Application.&lt;/p&gt;  &lt;p&gt;So there you have it. It’s DTA and DAC – but I think you’ll know the difference when the time comes to use one…&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=20206" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>The Top 20 Questions in Database Design</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/12/17/the-top-20-questions-in-database-design.aspx</link><pubDate>Thu, 17 Dec 2009 14:18:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:20063</guid><dc:creator>BuckWoody</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/20063.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=20063</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-FAMILY:'Calibri','sans-serif';COLOR:black;FONT-SIZE:11pt;mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;I'm still re-reading the "Fourth Paradigm" book by Microsoft Research, and one section continues to intrigues me. There's a part where the book explains database design, and puts forth that the most important thing when you're designing large data sets is to find out the "Top Twenty Questions" the database has to answer. The quote is this:&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY:'Calibri','sans-serif';COLOR:black;FONT-SIZE:11pt;mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;"Most selections involving human choices follow a 'long tail,' or so-called 1/f distribution, it is clear that the relative information in the queries ranked by importance is logarithmic, so the gain realized by going from approximately 20 (24.5) to 100 (26.5) is quite modest."&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY:'Calibri','sans-serif';COLOR:black;FONT-SIZE:11pt;mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;I find this facinating - it just doesn't seem to make "common" sense. Surely you have to ask a lot more questions than that to "get" the shape of the data? I researched the mathematical concept he's describing (&lt;A href="http://www.scholarpedia.org/article/1/f_noise"&gt;http://www.scholarpedia.org/article/1/f_noise&lt;/A&gt;), and I'll try some experiments here. I'll let you know what I uncover!&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY:'Calibri','sans-serif';COLOR:black;FONT-SIZE:11pt;mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&amp;nbsp;Here's the link for the book if you want to read it: &lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY:'Calibri','sans-serif';COLOR:black;FONT-SIZE:11pt;mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&lt;A href="http://research.microsoft.com/en-us/collaboration/fourthparadigm/4th_paradigm_book_complete_lr.pdf"&gt;http://research.microsoft.com/en-us/collaboration/fourthparadigm/4th_paradigm_book_complete_lr.pdf&lt;/A&gt; &lt;BR&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=20063" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item><item><title>The Coming Database Design Wave</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/12/16/the-coming-database-design-wave.aspx</link><pubDate>Wed, 16 Dec 2009 13:50:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:20014</guid><dc:creator>BuckWoody</dc:creator><slash:comments>4</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/20014.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=20014</wfw:commentRss><description>&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;Database design has been on my mind as of late – I’ve been teaching it in class, and I have a friend from Twitter that has a couple of questions. In fact, I think I’ll actually do a submission to PASS this year on this topic. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;Don’t think it has to do with you? Well, I’m seeing a new “wave” of design options coming at the data professional. Do these ring a bell?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;Traditional Logical/Physical Database Design Methodologies&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;Object-Role Modeling&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;EDMX&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;Entity Framework Code - .NET Classes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';COLOR:black;FONT-SIZE:10pt;"&gt;If any of these are new to you, get ready….&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=20014" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Aren’t DBA’s Just System Admins for Databases?</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/11/30/aren-t-dba-s-just-system-admins-for-databases.aspx</link><pubDate>Mon, 30 Nov 2009 16:37:32 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19335</guid><dc:creator>BuckWoody</dc:creator><slash:comments>8</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/19335.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19335</wfw:commentRss><description>&lt;p&gt;Last week I ran into an argument I’ve had since I left the mainframe space decades ago. A developer told me “DBA’s don’t design databases.” The inference was that DBA’s (i.e., Database Administrators) only worry about hardware, security, OS, database backups, things like that. He seemed amazed that a DBA would ever do “data” work.&lt;/p&gt;  &lt;p&gt;It may be the name. Perhaps the “admin” part confuses developers. Also, it is true that in some shops, a systems admin does double duty with Windows, SQL Server, and perhaps even mail and web admins. &lt;/p&gt;  &lt;p&gt;But there are a LOT of DBA’s, or as the term I like to use, “Data Professionals”, that actually DO get down in the trenches and design databases, write Transact-SQL code and stored procedures, and do almost everything in the database other than write middle-tier or User Interface (UI) code. Some I know even do that.&lt;/p&gt;  &lt;p&gt;So what if there is a miscommunication on this? Well, the ramifications can be huge. For one thing, there’s a lack of respect. That’s not called for ever, no matter what anyone’s role is. Also, one of the most impactful areas in a database is the design. When a DBA is asked to export data, tune a process, or troubleshoot an issue, it invariably involves the design. So when a DBA doesn’t get to do the design, they have to live with the results. And anything you’re responsible for when you don’t have the authority over is a recipe for stress.&lt;/p&gt;  &lt;p&gt;Another issue is that DBA’s “inherit” all kinds of data structures form around the company. From Microsoft Access to Excel, to amateur Business Analysts creating databases in the Express Editions, they deal with bad design day after day. The newer “modeling” languages that are coming into vogue will make this problem much worse. These languages do not take scale, extensibility, security or performance into account – they just make sure that the data ends up in the right place for that particular design, which is a recipe for data disaster when the “small application” the developer writes becomes a “mission critical” system the DBA has to troubleshoot at 2:00 A.M.&lt;/p&gt;  &lt;p&gt;So in case you’re a developer, and in case you think DBA’s “just do admin” – think again. DBA’s spend their whole day in this world, and can be a valuable asset to your development efforts. Bring them in early, bring them in often, and whatever you do – don’t design alone. Business Analysts, Developers and Data Professionals are needed to make a good, sustainable, secure, well-performing database.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=19335" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Rant/default.aspx">Rant</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Code that Writes Code</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/11/25/code-that-writes-code.aspx</link><pubDate>Wed, 25 Nov 2009 14:01:40 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19171</guid><dc:creator>BuckWoody</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/19171.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19171</wfw:commentRss><description>&lt;p&gt;I have scripts that re-create my databases for testing and development purposes. But sometimes I want to take the data from a set of tables and move it as well – I could use SSIS, or a SELECT INTO statement, but what if I want to “re-set” the data to a point in time? In other words, load it with some “base data”? &lt;/p&gt;  &lt;p&gt;I thought this might be a good place to demonstrate “code that writes code”. No, it isn’t that big of a deal – most DBAs know how to do this, but in the interest of those who don’t, I thought I would share.&lt;/p&gt;  &lt;p&gt;So the end result I want in this case is to have a bunch of INSERT statements that contain my base data from a table where that data already exists. I could script out the table from SSMS and use the replacement parameter feature to fill out each record individually:&lt;/p&gt;  &lt;p&gt;I have a table in one of my databases that I right-clicked to show the INSERT statement:&lt;/p&gt; &lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;     &lt;p&gt;-- Person&lt;/p&gt;   &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;     &lt;p&gt;INSERT&lt;/p&gt;   &lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;INTO&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; [WAVS]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;[dbo]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;[Person]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;[PersonName]&lt;/font&gt;&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[Street]&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[CityStateZip]&lt;/font&gt;    &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[PersonType]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;VALUES&lt;/font&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;PersonName&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;150&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonStreet&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;100&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonCityStateZip&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;255&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;   &lt;p&gt;&lt;/p&gt;   &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;PersonPersonType&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;varchar&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;100&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;),&amp;gt;)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333" size="2"&gt;I can use the CTRL-SHIFT-M keys to replace the VALUES part with the values I want.&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333" size="2"&gt;But I already had a copy of that “base” data before I turned the database over to the testers. Before I give it to them, I run code like this on each table – this one is for the &lt;em&gt;Person&lt;/em&gt; table above (note that there should only be two lines here):&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;font color="#808080"&gt;&lt;font color="#808080"&gt;&lt;font color="#333333"&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;           &lt;p&gt;&lt;font size="2"&gt;SELECT&lt;/font&gt;&lt;/p&gt;         &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;'INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES ('&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff00ff"&gt;&lt;font color="#ff00ff"&gt;CAST&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[PersonID] &lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;5&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;))+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [PersonName]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [Street]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [CityStateZip] &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''', '''&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; [PersonType] &lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font color="#ff0000"&gt;''')'&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;           &lt;p&gt;&lt;font size="2"&gt;FROM&lt;/font&gt;&lt;/p&gt;         &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; [WAVS]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[dbo]&lt;/font&gt;&lt;font color="#808080"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000"&gt;[Person]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;        &lt;p&gt;&lt;font color="#000000" size="2"&gt;When I run this code, I get these statements:&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font color="#0080c0" size="2"&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (1, 'Buck Woody', '123 Here Street', 'Covington, WA 98042', 'Vet')           &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (2, 'Jane Doe', '231 Function Ave', 'Redmond, WA 98052', 'Vet')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (3, 'Diane Wilson', '34251 Appt 3 7th Street', 'Seattle, WA 98061', 'Vet')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (4, 'John Kelso', '89734 Country Lane', 'Covington, WA 98042', 'Farmer')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (5, 'Marjorie Christian', '9893452 Changein Lane', 'Maple Valley, WA 98072', 'Farmer')            &lt;br /&gt;INSERT INTO [WAVS].[dbo].[Person] ([PersonID], [PersonName], [Street], [CityStateZip], [PersonType]) VALUES (6, 'Joanne Lister', '98904 Mapelwood Drive', 'Spokanne, WA 98045', 'Zoo Worker')&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;All I have to do is copy those statements into my “initialization” scripts just after the table creations, and then I can run them at will to create my new database (I know I can take a backup – I have reasons for not doing that).&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;There are two keys for writing code that writes code: The first is to simply use the single tick (') to write out what the end code should say (INSERT INTO, in my case) and then to use multiple ticks (''') when you want the code to contain the ticks themselves. This “escapes” the characters so that you can embed them. If you use SSMS to write your queries, the color coding will look as mine does above. You’ll also need to remember to CAST or CONVERT any data types that don’t concatenate (+) together well. In my case I had to CAST an integer value – but that’s OK, since it is only printing to the screen and I don’t include the ticks, the INSERT works fine.&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;You can use this method not only with INSERTS, but with lots of operations. And you can also even fire off the code once you create it – but that’s another post :)&lt;/font&gt;&lt;/p&gt;        &lt;p&gt;&lt;font size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;     &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=19171" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+Management+Studio/default.aspx">SQL Server Management Studio</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSMS/default.aspx">SSMS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/T-SQL/default.aspx">T-SQL</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Virtualization/default.aspx">Virtualization</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item><item><title>Changing the Primary Key After You Have Data</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/11/24/changing-the-primary-key-after-you-have-data.aspx</link><pubDate>Tue, 24 Nov 2009 13:25:22 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19147</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/19147.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19147</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/buckwoody/archive/2009/11/23/changing-the-primary-key-before-you-have-data.aspx" target="_blank"&gt;Yesterday I blogged about changing a Primary Key (PK)&lt;/a&gt; during the design phase, and before you have data in the database. Even then, it’s not trivial to change the data type or column(s) that make(s) up the PK. When you have data in that Primary Key and/or you have Foreign Keys (FK) that point to a PK field, this becomes a much more involved process.&lt;/p&gt;  &lt;p&gt;First, you MUST take a complete backup of the system, and you MUST do this work on a development system. You’re going to be manipulating base data, and in the worst kind of way. Why do I say that?&lt;/p&gt;  &lt;p&gt;There are three kinds of data problems. One is physical data corruption, and once you restore it (I don’t trust repair with data loss) then you know where the “good” data stops and starts. You know that the FKs are pointing to the right PKs, and that the data is readable. &lt;/p&gt;  &lt;p&gt;The second kind of data problem is “incorrect” entry, meaning that you put in “Buck Woodie” when you meant “Buck Woody”. This is also often correctable, as your Declarative Referential Integrity (DRI) will still keep that record together. It’s a simple matter to locate and correct.&lt;/p&gt;  &lt;p&gt;But the third kind of data problem is the worst. In this kind, the FKs point to the &lt;em&gt;wrong&lt;/em&gt; PK, or &lt;em&gt;not at all&lt;/em&gt;. Or perhaps some of the FK data is missing. The reason this is the worst is that the data cannot be trusted – did Buck Woody really pay for that purchase or was that payment from a different record? If the links are incorrect, everything will look fine, but it won’t be correct.&lt;/p&gt;  &lt;p&gt;So in the situation where you want to change the PKs when you already have data, one of the steps is to re-point the FKs to the proper PKs. Get this wrong and you’ll have “dirty data”. The only recourse there is to restore the backup and start over.&lt;/p&gt;  &lt;p&gt;I’m assuming that you have a REALLY GOOD reason to make this change, and that you’ve taken that backup and you’re on a test system. As Hannibal Lector would say: “Okeedokee – here we go.”&lt;/p&gt;  &lt;p&gt;I’ll describe two possible choices. In the first, understand and document the PK and FK relationships for each table. Then create queries that tie out the INSERTS for that data in the correct order, and include all fields for both tables, including the PKs in the parent table and the FKs in the child tables.&lt;/p&gt;  &lt;p&gt;With those INSERT statements made, drop the PK and FK constraints on all of the tables using the script I mentioned yesterday. Make your change to the data type (or field) in the tables. Then edit the INSERT statements to have the new value types, ensuring that the “sets” or records are kept together by keeping the FK’s pointing to the right PKs. Then re-apply the PK and FK constraints, watching for errors. With backups and scripts, you can make corrections along the way.&lt;/p&gt;  &lt;p&gt;The second method works much as the first, with the exception of using the INSERT statements. You can use SSIS or a third-party transfer process to actually move the data and change the data type or values “in flight”, although this requires more thought and planning in my experience.&lt;/p&gt;  &lt;p&gt;In any case, you should test the results thoroughly and ensure that you’re getting the data you expect. Communicate what you’re doing, and be ready to fall back to your backups at the first sign of trouble.&lt;/p&gt;  &lt;p&gt;Oh – since SQL Server 2005, you’ve been able to “relax” constraints to insert data. That won’t help you here, since you’re changing the entire key for whatever reason. That’s only meant to allow you to get data in when the key doesn’t change.&lt;/p&gt;  &lt;p&gt;OK – feel free to comment on this post, since there are other ways I didn’t cover. But if you’re reading my material or any of the comments, make sure you test it yourself – I might have missed something, no one is perfect, your situation may vary. Once again, you can see why I value a good design and ERD so highly – that way you never have to get here to begin with!&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=19147" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSMS/default.aspx">SSMS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category></item></channel></rss>