<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://consultingblogs.emc.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>Data Based</title><link>http://consultingblogs.emc.com/davidportas/default.aspx</link><description>Just some thoughts of mine</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>2 + 2 = ?</title><link>http://consultingblogs.emc.com/davidportas/archive/2009/08/26/2-2.aspx</link><pubDate>Wed, 26 Aug 2009 20:02:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:16126</guid><dc:creator>David.Portas</dc:creator><slash:comments>1</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/16126.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=16126</wfw:commentRss><description>&lt;p&gt;As a concise example of the evils of &lt;a href="http://blogs.conchango.com/davidportas/archive/2009/06/24/db2-9-7-and-database-type-safety.aspx"&gt;type coercion&lt;/a&gt; I came up with the following:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;INSERT INTO t      &lt;br&gt;VALUES (       &lt;br&gt;CAST(2 AS INT),       &lt;br&gt;CAST(2 AS INT)); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT      &lt;br&gt;CASE WHEN x + z = 4 THEN '4' ELSE 'NOT 4' END xPLUSz       &lt;br&gt;FROM t;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Result:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;xPLUSz      &lt;br&gt;------       &lt;br&gt;NOT 4&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It is left as an exercise for the reader to work out what types x and z might be!&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=16126" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Data/default.aspx">Data</category></item><item><title>The Relational Model turns 40</title><link>http://consultingblogs.emc.com/davidportas/archive/2009/08/18/the-relational-model-turns-40.aspx</link><pubDate>Tue, 18 Aug 2009 21:55:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:16082</guid><dc:creator>David.Portas</dc:creator><slash:comments>2</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/16082.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=16082</wfw:commentRss><description>&lt;P&gt;The Relational Data Model is 40 years old. &lt;A href="http://www.research.ibm.com/resources/news/20030423_edgarpassaway.shtml"&gt;Edgar Codd&lt;/A&gt; first described the idea that databases could be constructed from mathematical relations in an internal IBM Research &lt;A href="http://www.sigmod.org/sigmod/record/issues/0903/p17.40year.codd.pdf"&gt;report&lt;/A&gt; in August 1969. The following year his more famous paper on the same topic was published for public consumption. So began a revolution. Data was liberated from its physical representation and thereafter the most complex data processing problems could be solved using only a few simple building blocks (the eight basic operators of Codd’s relational algebra). Few concepts in the history IT have made such an impact or endured for so long.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sigmod.org/sigmod/record/issues/0903/p17.40year.codd.pdf"&gt;&lt;IMG title="Derivability, Redundancy and Consistency of Relations Stored in Large Data Banks" style="BORDER-TOP-WIDTH:0px;DISPLAY:inline;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height=260 alt="Derivability, Redundancy and Consistency of Relations Stored in Large Data Banks" src="http://blogs.conchango.com/blogs/davidportas/codd1969_1901152E.jpg" width=260 border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;At this point I could try to write something profound about what the next 40 years might hold... I’m not foolish enough to predict anything like that far ahead though! For sure there is a lot more that &lt;EM&gt;could&lt;/EM&gt; be done. The SQL systems that most of us use are still some way short of what Codd envisaged even four decades ago. It seems pretty clear that technology already exists to make possible much better database systems than we have today. Solid-state storage for example should make it possible to achieve far greater Physical Data Independence (database representation that is more abstracted from its internal storage structures). Richer type support in databases is something that database vendors have been improving but there is still some way to go – in particular type-inheritance isn’t well-supported by most DBMSs. Self-optimising databases is one area where I expect we’ll see a lot more innovation.&amp;nbsp; And then of course there is ever more scalability and distributed database technology, which brings me to the cloud and distributed databases…&lt;/P&gt;
&lt;P&gt;My potentially subversive question is this: &lt;EM&gt;Do we actually need new data models for the cloud?&lt;/EM&gt; It seems that we do need different and hopefully better &lt;EM&gt;implementations&lt;/EM&gt; of database systems than we have in centralised data centres. We will go on using XML stores and other types of storage too. But the relational model still ought to have a central role to play in cloudy, distributed data stores as well as the centralised ones.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf"&gt;Brewer&lt;/A&gt; conjectures that we may need to accept partial or eventual consistency of data if we desire a system that’s both available and partitioned. Two observations about this seem important. Firstly, consistency guaranteed at &lt;EM&gt;some&lt;/EM&gt; point will continue to be critical for the vast majority of non-trivial systems. No business is ever giving up consistency and accuracy as desirable goals because trust is the basis of every business model out there. Secondly, &lt;EM&gt;eventual&lt;/EM&gt; consistency means that fewer business rules are implemented in the declarative manner that we are used to, i.e. they are evaluated some time after the event rather than at transaction time.&lt;/P&gt;
&lt;P&gt;This could actually suit the relational model very well. Because the RM&amp;nbsp;doesn't have&amp;nbsp;any navigational structures it can easily accommodate data that is late arriving. Provided no constraint is actually broken (as if we aren’t using &lt;EM&gt;declarative referential integrity&lt;/EM&gt; for example) it is perfectly OK for some tuples to arrive “late” in our relational model. We can still query and join on the tuples that are present, we can derive place-holders for tuples that are missing (think outer joins) and we can apply integrity rules to data when it does arrive. This is in stark contrast to navigational models (like XML and other hierarchies) where an element &lt;EM&gt;must&lt;/EM&gt; exist before its child elements can exist.&lt;/P&gt;
&lt;P&gt;Another desirable property of large distributed systems is a flexible and dynamic structure. RM is good here too. In principle relational schemas can be highly dynamic but unfortunately this is one area where SQL systems are found wanting. In a relational system, changing the set of attributes of a relation ought to be as simple as writing the query that transforms the data and then assigning the result of that query to a new relation variable. Potentially this needs to involve little or no change to the underlying storage and can therefore be a near-instantaneous metadata operation. SQL DBMSs make extremely heavy work of such a simple task however, which is why SQL databases are often difficult to change and adapt.&lt;/P&gt;
&lt;P&gt;Yet another thing on the distributed storage wish-list is rich type support – support for storing documents, images, XML and other objects in databases just as easily as strings and numbers. As already mentioned, SQL systems are doing some of that already and vendors will no doubt continue to improve type support.&lt;/P&gt;
&lt;P&gt;The many familiar and valid criticisms of SQL (see for example the “&lt;A href="http://blog.oskarsson.nu/2009/06/nosql-debrief.html"&gt;NoSQL&lt;/A&gt;” line of thought) are just that – problems with the SQL model and&amp;nbsp;SQL DBMS&amp;nbsp;limitations rather than with the relational model. (See also &lt;A href="http://matthew.yumptious.com/2009/07/databases/nosql-and-the-relational-model-dont-throw-the-baby-out-with-the-bathwater/"&gt;NoSQL and the Relational Model: don’t throw the baby out with the bathwater&lt;/A&gt;). So even after 40 years I still think the relational model is the coolest game in data-land, and perhaps the best is still to come because RM’s potential has never yet been fully realised in mainstream database software. Kudos Mr Codd!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.conchango.com/blogs/davidportas/codd_08F4D728.jpg"&gt;&lt;IMG title=E.F.Codd style="BORDER-RIGHT:0px;BORDER-TOP:0px;DISPLAY:inline;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height=120 alt=E.F.Codd src="http://blogs.conchango.com/blogs/davidportas/codd_thumb_3675F6EB.jpg" width=86 border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=16082" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Data/default.aspx">Data</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Cloud/default.aspx">Cloud</category></item><item><title>UPDATE FROM the Sybase code museum</title><link>http://consultingblogs.emc.com/davidportas/archive/2009/06/24/update-from-the-sybase-code-museum.aspx</link><pubDate>Wed, 24 Jun 2009 21:57:59 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:15605</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/15605.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=15605</wfw:commentRss><description>&lt;p&gt;UPDATE FROM is dead … or it should be. &lt;a href="http://sqlblog.com/blogs/hugo_kornelis/archive/2008/03/10/lets-deprecate-update-from.aspx"&gt;Hugo Kornelis&lt;/a&gt; has done a good job of explaining why.&lt;/p&gt;  &lt;p&gt;Apart from a badly thought out and non-portable syntax, UPDATE FROM suffers a notorious bug/feature. I say “notorious” but it’s probably not notorious enough because it is still common to see people get tripped up by it. If I write:&lt;/p&gt;  &lt;p&gt;UPDATE Alpha    &lt;br /&gt;SET z = Beta.z     &lt;br /&gt;FROM Alpha     &lt;br /&gt;JOIN Beta     &lt;br /&gt;ON Alpha.x = Beta.x ;&lt;/p&gt;  &lt;p&gt;and if Beta.x is not unique then Alpha.z will get updated with some &lt;em&gt;random&lt;/em&gt; value from one of the matching rows in Beta.z. This is documented in &lt;a href="http://technet.microsoft.com/en-us/library/ms177523.aspx"&gt;Books Online&lt;/a&gt; as follows:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;“The results of an UPDATE statement are undefined if the statement includes a FROM clause that is not specified in such a way that only one value is available for each column occurrence that is updated, that is if the UPDATE statement is not deterministic.”&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb510625.aspx"&gt;MERGE&lt;/a&gt; handles the same situation more wisely and safely: it returns a runtime error if the join is non-deterministic:&lt;/p&gt;  &lt;p&gt;MERGE INTO Alpha    &lt;br /&gt;USING Beta     &lt;br /&gt;ON Alpha.x = Beta.x     &lt;br /&gt;WHEN MATCHED THEN UPDATE     &lt;br /&gt;SET z = Beta.z ;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Msg 8672, Level 16, State 1, Line 42      &lt;br /&gt;The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;MERGE is also standard SQL, works in other DBMSs and frequently results in more efficient execution plans than UPDATE FROM.&lt;/p&gt;  &lt;p&gt;UPDATE FROM isn’t originally Microsoft’s fault because it’s a legacy of SQL Server’s ancient historical roots at Sybase. But it is Microsoft’s fault they haven’t deprecated it yet. You can vote for deprecating UPDATE FROM on Connect:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=332437"&gt;http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=332437&lt;/a&gt;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=15605" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>DB2 9.7 and Database Type Safety</title><link>http://consultingblogs.emc.com/davidportas/archive/2009/06/24/db2-9-7-and-database-type-safety.aspx</link><pubDate>Wed, 24 Jun 2009 21:01:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:15604</guid><dc:creator>David.Portas</dc:creator><slash:comments>1</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/15604.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=15604</wfw:commentRss><description>&lt;p&gt;DB2 has some new features that are aimed at customers who want to transition from Oracle to DB2:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www-05.ibm.com/ch/events/symposium/pdf/9_M_Obrecht_IBM_Symposium_2009.pdf" href="http://www-05.ibm.com/ch/events/symposium/pdf/9_M_Obrecht_IBM_Symposium_2009.pdf"&gt;http://www-05.ibm.com/ch/events/symposium/pdf/9_M_Obrecht_IBM_Symposium_2009.pdf&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;IBM are emphasising the improved snapshot isolation, PL/SQL support and packages (“modules” in IBM’s terms).&lt;/p&gt;  &lt;p&gt;One “feature” that caught my eye is support for &lt;i&gt;implicit conversion&lt;/i&gt;. This is a surprise to me. In most areas of software engineering strong typing is considered not just desirable but pretty essential to program correctness and early identification of bugs. I don’t think that reducing or removing type safety is a good way to improve database languages.&lt;/p&gt;  &lt;p&gt;In SQL Server, Oracle and other DBMSs we already have to live with implicit typing (type coercion) and the problems it causes. SQL Server won’t complain at compile time if I write the following two lines in the same procedure or script:&lt;/p&gt;  &lt;p&gt;SELECT col1 FROM tbl WHERE col2 = &lt;font color="#ff0000"&gt;CAST(1 AS INT);&lt;/font&gt;     &lt;br&gt;SELECT col1 FROM tbl WHERE col2 = &lt;font color="#ff0000"&gt;CAST('2' AS VARCHAR(10));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The effect is that SQL Server recklessly and silently casts strings as numbers and won’t even give a runtime error until the data itself causes the conversion to break. Getting it right therefore requires much more effort than it would do if types were checked at compile time.&lt;/p&gt;  &lt;p&gt;Erland Sommarskog has posted a feedback item requesting that stricter compile time checking be incorporated in a future version of SQL Server. Please rate it if you agree:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=260762" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=260762"&gt;http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=260762&lt;/a&gt;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=15604" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category></item><item><title>SQL Server 2008 - Why I'm not waiting for SP1!</title><link>http://consultingblogs.emc.com/davidportas/archive/2008/11/21/sql-server-2008-why-i-m-not-waiting-for-sp1.aspx</link><pubDate>Fri, 21 Nov 2008 16:31:42 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:13360</guid><dc:creator>David.Portas</dc:creator><slash:comments>1</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/13360.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=13360</wfw:commentRss><description>&lt;p&gt;Whether and when to upgrade to SQL Server 2008? It seems that there is still a school of thought that the release version of a product is not to be trusted and that the best policy is to &amp;quot;wait for SP1&amp;quot;. Now this has never made much sense to me, not least because Service Packs can mean quite different things in different products. Sticking with SQL Server 2008 though, I believe there are plenty of reasons to upgrade now and NOT to wait for SP1.&lt;/p&gt;  &lt;p&gt;Firstly, SQL Server 2008 is an extremely high quality and stable product and has already notched up a great many server-years of collective testing, both before release and after. I personally have been developing and testing with it on projects for a year now and it has been the best quality preview version of the product I've ever worked with. SQL Server 2008 RTM is in very much better shape now than SQL Server 2005 was at this point in its life.&lt;/p&gt;  &lt;p&gt;Secondly, it has to be said that the history of SQL Server Service Packs is not an entirely happy one. There have been some very unfortunate problems with SQL SPs. For sure, the SQL Server team will learn from their mistakes but the fact is that an SP is never going to get the level of testing at customer sites that a major release gets. This is natural enough because SPs rarely contain new functionality so it's harder to justify the investment needed to build and test with the beta versions of SPs.&lt;/p&gt;  &lt;p&gt;In terms of quantifiable risk then, installing a 2008 service pack right after release is potentially far more risky than installing SQL Server 2008 RTM right now.&lt;/p&gt;  &lt;p&gt;Thirdly, there are the real returns you could get from upgrading to 2008 even with minimal effort. Upgrading from 2000 to 2005 was and is a big undertaking. Between 2000 and 2005 there is a whole raft of new features, deprecated features, breaking changes - all of which adds up to a lot of regression testing and potential development effort to take advantage of new features. In comparison, the additional effort to move from 2005 to 2008 or from 2000 to 2008&amp;#160; is a far smaller piece of work. Fewer new things will be broken or need re-working. Plus you can take advantage of new features like compression and policy based management with zero change to existing applications.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.technet.com/andrew/archive/2008/11/21/when-to-upgrade-to-sql-server-2008.aspx"&gt;Andrew Fryer says&lt;/a&gt; that you may have to wait a long time for a SQL 2008 SP. At the &lt;a href="http://www.sqlserverfaq.com/"&gt;UK User Group&lt;/a&gt; meeting last night he also had a suggestion. Even if you aren't upgrading your servers yet, at least install and use 2008 Management Studio so that you can take advantage of the new features in the tool!&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=13360" width="1" height="1"&gt;</description></item><item><title>SQL Server 2008 RTM</title><link>http://consultingblogs.emc.com/davidportas/archive/2008/08/06/sql-server-2008-rtm.aspx</link><pubDate>Wed, 06 Aug 2008 18:29:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:12150</guid><dc:creator>David.Portas</dc:creator><slash:comments>1</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/12150.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=12150</wfw:commentRss><description>&lt;P&gt;&lt;IMG title="SQL Server 2008" style="WIDTH:640px;HEIGHT:155px;" height=155 alt="SQL Server 2008" src="http://blogs.technet.com/blogfiles/andrew/WindowsLiveWriter/SQLServer2008RC0_F15A/image_2.png" width=640&gt;&lt;/P&gt;
&lt;P&gt;SQL Server 2008 is out! All editions are on MSDN now except for Express, which should hopefully follow soon. Enjoy!&lt;/P&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=12150" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>Update on T-SQL MERGE</title><link>http://consultingblogs.emc.com/davidportas/archive/2008/06/09/update-on-t-sql-merge.aspx</link><pubDate>Mon, 09 Jun 2008 17:21:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:11396</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/11396.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=11396</wfw:commentRss><description>&lt;P&gt;The MERGE syntax I used &lt;A href="http://blogs.conchango.com/davidportas/archive/2007/11/14/SQL-Server-2008-MERGE.aspx"&gt;here&lt;/A&gt; has changed. In 2008 RC0 the "WHEN SOURCE NOT MATCHED" clause&amp;nbsp;is replaced with&amp;nbsp;"WHEN NOT MATCHED BY SOURCE" which is supposed to make the meaning clearer.&lt;/P&gt;
&lt;P&gt;Although MERGE is part of standard SQL 2003 it's worth noting that the SOURCE NOT MATCHED / NOT MATCHED BY SOURCE clause is not part of the standard. It's an extension added by Microsoft - a very useful one in my view.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;MERGE INTO a &lt;BR&gt;USING b &lt;BR&gt;ON a.keycol = b.keycol &lt;BR&gt;WHEN MATCHED THEN &lt;BR&gt;UPDATE SET &lt;BR&gt;&amp;nbsp; col1 = b.col1, &lt;BR&gt;&amp;nbsp; col2 = b.col2, &lt;BR&gt;&amp;nbsp; col3 = b.col3 &lt;BR&gt;WHEN NOT MATCHED THEN&amp;nbsp;&lt;BR&gt;&amp;nbsp; INSERT (keycol, col1, col2, col3)&amp;nbsp;&lt;BR&gt;&amp;nbsp; VALUES (b.keycol, b.col1, b.col2, b.col3) &lt;BR&gt;&lt;FONT color=#ff0000&gt;WHEN NOT MATCHED BY SOURCE&lt;/FONT&gt; THEN&amp;nbsp;&lt;BR&gt;&amp;nbsp; DELETE;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=11396" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>SQL Server 2008 RC0</title><link>http://consultingblogs.emc.com/davidportas/archive/2008/06/09/sql-server-2008-rc0.aspx</link><pubDate>Mon, 09 Jun 2008 16:50:13 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:11393</guid><dc:creator>David.Portas</dc:creator><slash:comments>2</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/11393.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=11393</wfw:commentRss><description>&lt;p&gt;&lt;img src="http://blogs.technet.com/blogfiles/andrew/WindowsLiveWriter/SQLServer2008RC0_F15A/image_2.png" /&gt;&lt;/p&gt;  &lt;p&gt;SQL Server 2008 Release Candidate 0 (build 10.0.1442.32) was released to MSDN and TechNet subscribers on Friday. It should be available to everyone else very soon via the Connect site.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/subscriptions/default.aspx" href="http://msdn.microsoft.com/en-us/subscriptions/default.aspx"&gt;http://msdn.microsoft.com/en-us/subscriptions/default.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://technet.microsoft.com/en-us/subscriptions/default.aspx" href="http://technet.microsoft.com/en-us/subscriptions/default.aspx"&gt;http://technet.microsoft.com/en-us/subscriptions/default.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Apart from the new branding (see above) the goodies in this release include some Management Studio enhancements: object search, T-SQL debugger and PowerShell support. Yes, the debugger is back for those who miss it from SQL Server 2000 days!&lt;/p&gt;  &lt;p&gt;What's also new is that multiple editions are now included in a single package, so you get Express, Standard, Enterprise, etc instead of just Developer. A product key is required to install the paid-for editions.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.conchango.com/blogs/davidportas/WindowsLiveWriter/SQLServer2008RC0_BE8A/SQLServer2008RC0Setup_2.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="184" alt="SQLServer2008RC0Setup" src="http://blogs.conchango.com/blogs/davidportas/WindowsLiveWriter/SQLServer2008RC0_BE8A/SQLServer2008RC0Setup_thumb_2.jpg" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;SQL Server Express Edition 64 bit&lt;/h2&gt;  &lt;p&gt;I have seen no info at all from Microsoft about this but RC0 does include a 64 bit version of Express Edition. This is the first native 64 bit release of Express. SQL Server 2005 Express Edition is 32 bit and WOW only.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT @@VERSION;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;--------------------------------------------------------------------------------------------------------     &lt;br /&gt;Microsoft SQL Server 2008 (CTP) - 10.0.1442.32 (X64)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; May 29 2008 23:52:04       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Copyright (c) 1988-2007 Microsoft Corporation      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Express Edition with Advanced Services (64-bit) on Windows NT 5.2 &amp;lt;X64&amp;gt; (Build 3790: Service Pack 2) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;(1 row(s) affected)&lt;/font&gt;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=11393" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>Not the model, Bill</title><link>http://consultingblogs.emc.com/davidportas/archive/2008/02/12/Not-the-model_2C00_-Bill.aspx</link><pubDate>Tue, 12 Feb 2008 22:27:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:9733</guid><dc:creator>David.Portas</dc:creator><slash:comments>1</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/9733.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=9733</wfw:commentRss><description>&lt;br /&gt;According to &lt;a href="http://www.infoworld.com/article/08/02/11/gates-declarative_1.html"&gt;InfoWorld&lt;/a&gt;, Bill Gates thinks that declarative modelling of business logic has not caught on because of &amp;quot;weak models&amp;quot;.&lt;br /&gt;&lt;br /&gt;This is a surprise. E.F.Codd&amp;#39;s earliest papers on the Relational Model described a relational calculus for the purpose of supporting declarative business logic. Even the SQL standards committee added some powerful features to standard SQL, such as CREATE ASSERTION and generalised CHECK constraints with subqueries. Despite this, InfoWorld identifies the Relational Model as one of the &amp;quot;weak&amp;quot; models referred to by Gates!&lt;br /&gt;&lt;br /&gt;What is stopping people putting declarative business logic in their data models today? The answer is not the model. It is the DBMS products that are supposed to implement the model. Here&amp;#39;s what Terry Halpin said about declarative constraint support in SQL back in 2001&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&amp;quot;Although the above SQL syntax [CREATE DOMAIN and CHECK constraint with subquery] is legal as far back as SQL-92, some commercial versions of SQL do not yet support all of this syntax. For data definition, some versions have barely progressed beyond the old SQL-89 standard (which had no domain clauses, and restricted check clauses to conditions on a single row). In practice, some features of a relational schema may need to be specified as a procedural code rather than declaratively.&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;/em&gt;(Information Modeling and Relational Databases, p411)&lt;br /&gt;&lt;br /&gt;In 2000, Fabian Pascal wrote:&lt;br /&gt;&lt;em&gt;&lt;br /&gt;&amp;quot;most commercial DBMSs have not implemented the [SQL] standard&amp;#39;s advanced level integrity features. Some implement integrity procedurally via user-written stored procedures expressed in proprietary SQL extensions that can be quite complex, vary across products and have various limitations.&amp;quot;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;(Practical Issues in Database Management, p64)&lt;br /&gt;&lt;br /&gt;And here&amp;#39;s my take on the same problem:&lt;br /&gt;&lt;a href="http://blogs.conchango.com/davidportas/archive/2007/02/19/Trouble-with-CHECK-Constraints.aspx"&gt;http://blogs.conchango.com/davidportas/archive/2007/02/19/Trouble-with-CHECK-Constraints.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Database practitioners have been saying for years that most SQL DBMSs do a poor job of supporting declarative business logic. Dear Bill: the relational model is just great. Please fix the omissions in the current products before going on to invent whole new ones!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=9733" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Data/default.aspx">Data</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Data+Modelling/default.aspx">Data Modelling</category></item><item><title>SQL Server 2008 November CTP</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/11/19/SQL-Server-2008-November-CTP.aspx</link><pubDate>Mon, 19 Nov 2007 18:37:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:9102</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/9102.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=9102</wfw:commentRss><description>&lt;p&gt;CTP5 is available today!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BF4C5CA-B905-4EBC-8901-1D4C1D1DA884"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyId=3BF4C5CA-B905-4EBC-8901-1D4C1D1DA884&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Jamie has already &lt;a href="http://blogs.conchango.com/jamiethomson/" title="SSIS Junkie"&gt;blogged&lt;/a&gt; about some of the new goodies in CTP5, which include Intellisense&amp;nbsp;for Management Studio. Also new in this release is the FileStream feature, which is something&amp;nbsp;I&amp;#39;ve been working with recently. I&amp;nbsp;plan to&amp;nbsp;have more to say about FileStream soon.&lt;br /&gt;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=9102" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>SQL Server 2008 MERGE</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/11/14/SQL-Server-2008-MERGE.aspx</link><pubDate>Wed, 14 Nov 2007 21:52:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:9059</guid><dc:creator>David.Portas</dc:creator><slash:comments>3</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/9059.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=9059</wfw:commentRss><description>&lt;p&gt;MERGE is a new DML statement in SQL Server 2008. Microsoft have implemented the ISO SQL 2003 and 2007 standard MERGE statement (as seen in Oracle and DB2) and added some extensions of their own.&lt;/p&gt;&lt;p&gt;In a nutshell, MERGE allows you to perform simultaneous UPDATE, INSERT and/or DELETE operations on one table. There are new physical operators that combine these operations so that they can be performed in a single scan rather than multiple scans.&lt;/p&gt;&lt;p&gt;MERGE has loads of possible applications. For the first time you can assign the contents of one table or query to another in a single operation. The following example requires SQL Server 2008 CTP4. Given this schema and data:&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;CREATE TABLE a&lt;br /&gt;&amp;nbsp;(keycol INT PRIMARY KEY,&lt;br /&gt;&amp;nbsp; col1 INT NOT NULL,&lt;br /&gt;&amp;nbsp; col2 INT NOT NULL,&lt;br /&gt;&amp;nbsp; col3 INT NOT NULL);&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;CREATE TABLE b&lt;br /&gt;&amp;nbsp;(keycol INT PRIMARY KEY,&lt;br /&gt;&amp;nbsp; col1 INT NOT NULL,&lt;br /&gt;&amp;nbsp; col2 INT NOT NULL,&lt;br /&gt;&amp;nbsp; col3 INT NOT NULL);&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;INSERT INTO a VALUES (1,0,0,0),(2,0,0,0);&lt;br /&gt;INSERT INTO&amp;nbsp;b VALUES (1,1,1,1),(3,3,3,3);&lt;/font&gt;&lt;/p&gt;&lt;p&gt;The following MERGE will populate table a with the same data as table b:&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;MERGE INTO a&lt;br /&gt;USING b&lt;br /&gt;&amp;nbsp;ON a.keycol = b.keycol&lt;br /&gt;WHEN MATCHED THEN&lt;br /&gt;&amp;nbsp;UPDATE SET&lt;br /&gt;&amp;nbsp; col1 = b.col1,&lt;br /&gt;&amp;nbsp; col2 = b.col2,&lt;br /&gt;&amp;nbsp; col3 = b.col3&lt;br /&gt;WHEN NOT MATCHED THEN&lt;br /&gt;&amp;nbsp;INSERT (keycol, col1, col2, col3)&lt;br /&gt;&amp;nbsp;VALUES (b.keycol, b.col1, b.col2, b.col3)&lt;br /&gt;WHEN SOURCE NOT MATCHED THEN&lt;br /&gt;&amp;nbsp;DELETE;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;In the relational world this is the operation known as Relational Assignment ie:&lt;/p&gt;&lt;p&gt;&amp;nbsp;a := b&lt;/p&gt;&lt;p&gt;Unfortunately the SQL syntax is less pretty and requires just a little more typing!&lt;/p&gt;&lt;p&gt;MERGE&amp;nbsp;also makes a good &amp;quot;upsert&amp;quot; for application CRUD stored procedures, removing the need for constructs like:&lt;/p&gt;&lt;p&gt;IF NOT EXISTS ...&lt;br /&gt;&amp;nbsp; INSERT ...&lt;/p&gt;&lt;p&gt;Here&amp;#39;s an example I created today. It inserts a new Vendor if and only if the name doesn&amp;#39;t already exist. Whether the name previously existed or not, it returns the IDENTITY value of the existing or newly inserted row.&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;CREATE&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;PROC&lt;/span&gt; dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;usp_VendorUpsert&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;(&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;@pVendorID &lt;span style="color:blue;"&gt;INT&lt;/span&gt; &lt;span style="color:blue;"&gt;OUTPUT&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@pVendorName &lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;80&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:green;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;AS&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;BEGIN&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;SET&lt;/span&gt; &lt;span style="color:blue;"&gt;NOCOUNT&lt;/span&gt; &lt;span style="color:blue;"&gt;ON&lt;/span&gt;&lt;span style="color:gray;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;MERGE&lt;/span&gt; dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;Vendor t&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;USING&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; @pVendorName&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;/span&gt; p&lt;span style="color:gray;"&gt;(&lt;/span&gt;VendorName&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;ON&lt;/span&gt; t&lt;span style="color:gray;"&gt;.&lt;/span&gt;VendorName &lt;span style="color:gray;"&gt;=&lt;/span&gt; @pVendorName&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;WHEN NOT&lt;/span&gt; MATCHED &lt;span style="color:blue;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;VendorName&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;@pVendorName&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;WHEN&lt;/span&gt; MATCHED &lt;span style="color:blue;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color:blue;"&gt;SET&lt;/span&gt; @pVendorID &lt;span style="color:gray;"&gt;=&lt;/span&gt; VendorID&lt;span style="color:gray;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;SET&lt;/span&gt; @pVendorID &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;COALESCE&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;SCOPE_IDENTITY&lt;/span&gt;&lt;span style="color:gray;"&gt;(),&lt;/span&gt;@pVendorID&lt;span style="color:gray;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:gray;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;END&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0cm 0cm 0pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;color:blue;font-family:'Courier New';"&gt;RETURN&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It&amp;#39;s amazing that it took nearly 20 years for the SQL standards committee to come up with MERGE. Perhaps the delay is a legacy of the decision to make INSERT, UPDATE and DELETE the basic data update operators. INSERT, UPDATE and DELETE can all be defined as different kinds of relational assignment - assignment being the most basic type of update possible. So arguably MERGE is the more primitive and fundamental data update operator that ought to have been around earlier rather than later.&lt;br /&gt;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=9059" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>Relational database pioneer doesn't quite say technology is obsolete!</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/09/16/Relational-database-pioneer-doesn_2700_t-quite-say-technology-is-obsolete_2100_.aspx</link><pubDate>Sun, 16 Sep 2007 20:10:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:8471</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/8471.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=8471</wfw:commentRss><description>&lt;p&gt;According to &lt;a href="http://www.computerworld.com/action/article.do?command=viewArticleBasic&amp;amp;articleId=9034619" title="Relational database pioneer says technology is obsolete"&gt;Computerworld&lt;/a&gt;, Mike Stonebraker says &lt;em&gt;&amp;quot;RDBMSes, are &amp;#39;long in the tooth&amp;#39; and &amp;#39;should be considered legacy technology&amp;#39;&amp;quot;&lt;/em&gt;. Knowing Stonebraker&amp;#39;s work and reputation that seemed like some pretty startling information! It was less of a surprise to find that Computerworld hadn&amp;#39;t quite got it right though...&lt;/p&gt;&lt;p&gt;You can read Mike Stonebraker&amp;#39;s actual words at &lt;a href="http://www.databasecolumn.com/"&gt;www.databasecolumn.com&lt;/a&gt;. He makes it clear that he&amp;#39;s talking about the technology used for current DBMS &lt;em&gt;implementations&lt;/em&gt;, not about the relational model or the SQL model itself. The columnar technology that Stonebraker has championed for years isn&amp;#39;t an alternative data model at all; it&amp;#39;s a particular mode of storage that in principle could be used by any DBMS,&amp;nbsp;whether&amp;nbsp;relational or not. As far as I know it has been used pretty much exclusively in SQL DBMSs (Sybase IQ for example).&lt;/p&gt;&lt;p&gt;Column store is perfect for BI and analytics. What would be even&amp;nbsp;nicer would be to have the choice of column store or row store (or both) in a single DBMS. In fact I&amp;#39;d like to discard altogether the assumption made by most major DBMSs - that a base table automatically defines the&amp;nbsp;main unit of storage.&lt;/p&gt;&lt;p&gt;It ought to be possible to map any selection, projection or join of tables into their own storage and to create redundant storage structures where necessary to support the best optimisations for different queries. Today, we have to use three different structures to achieve those things: partitions are a means of storing selections, indexes store projections, and &amp;quot;materialised&amp;quot; views are a&amp;nbsp;slightly roundabout means of persisting joins (why do we have to create a view just in order to change the&amp;nbsp;internal type&amp;nbsp;of storage?). Each of those techniques&amp;nbsp;have their own&amp;nbsp;particular advantages and disadvantages.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=8471" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Data/default.aspx">Data</category></item><item><title>A note on Updateable CTEs</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/07/26/A-note-on-Updateable-CTEs.aspx</link><pubDate>Thu, 26 Jul 2007 20:47:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:7820</guid><dc:creator>David.Portas</dc:creator><slash:comments>2</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/7820.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=7820</wfw:commentRss><description>&lt;p&gt;One of my regular gripes about SQL Server concerns the number of Transact SQL features that give nondeterministic results. Unfortunately SQL Server 2005 added to the list of those. One of the new ones is ROW_NUMBER(), which is strictly due to ANSI/ISO rather than Microsoft. ROW_NUMBER() is inherently non-deterministic unless the PARTITION / ORDER BY criteria define a unique criteria for each row - something that isn&amp;#39;t mandatory. What I think is surprising however, is Microsoft&amp;#39;s approach to updateable views and CTE&amp;#39;s, which gives&amp;nbsp;an interesting twist to the effect of ROW_NUMBER().&lt;/p&gt;&lt;p&gt;For example, ROW_NUMBER() can be used to solve the problem of removing duplicates from a set and it&amp;#39;s undeniably useful for that purpose. Here&amp;#39;s an apparently simple example. The goal is to delete all but one row for each distinct value of Z.&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;CREATE TABLE tbl (x INT NOT NULL PRIMARY KEY, z CHAR(1) NOT NULL);&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;INSERT INTO tbl (x,z) VALUES (1,&amp;#39;A&amp;#39;);&lt;br /&gt;INSERT INTO tbl (x,z) VALUES (2,&amp;#39;A&amp;#39;);&lt;br /&gt;INSERT INTO tbl (x,z) VALUES (3,&amp;#39;B&amp;#39;);&lt;br /&gt;INSERT INTO tbl (x,z) VALUES (4,&amp;#39;B&amp;#39;);&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;WITH t(r) AS /* Updateable CTE */&lt;br /&gt;&amp;nbsp;(SELECT ROW_NUMBER() OVER (PARTITION BY z ORDER BY z)&lt;br /&gt;&amp;nbsp; FROM tbl)&lt;br /&gt;&amp;nbsp;DELETE t WHERE r &amp;gt; 1;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;The problem is: which rows get deleted? The CTE doesn&amp;#39;t contain a key, in fact it doesn&amp;#39;t contain anything except the ROW_NUMBER() in column &amp;quot;r&amp;quot;. The ORDER BY clause doesn&amp;#39;t reference a key either which means the number returned for each row is nondeterministic. Yet despite these facts the CTE is still updateable. I was surprised when I first discovered that the DELETE statement above is legal. I was even more surprised to find that Books Online is totally silent on the point of exactly when a CTE is updateable and when it isn&amp;#39;t. The lack of documentation is a serious omission because those who have been using SQL Server for a few years will know that undefined behaviour tends to get dropped or changed between releases.&lt;/p&gt;&lt;p&gt;Right now, my habit is that if I need to update a CTE then I make sure it contains a key. Usually it makes sense for the OVER... ORDER BY clause to use a key also. Like:&lt;/p&gt;&lt;p&gt;&lt;font face="courier new,courier"&gt;WITH t(x,r) AS /* Updateable CTE */&lt;br /&gt;&amp;nbsp;(SELECT x, ROW_NUMBER() OVER (PARTITION BY z ORDER BY x)&lt;br /&gt;&amp;nbsp; FROM tbl)&lt;br /&gt;&amp;nbsp;DELETE t WHERE r &amp;gt; 1;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;(note the difference: SELECT x, ... ORDER BY x).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=7820" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>SQL Server 2008 June CTP</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/06/04/SQL-Server-2008-June-CTP.aspx</link><pubDate>Mon, 04 Jun 2007 14:16:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:7135</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/7135.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=7135</wfw:commentRss><description>&lt;p&gt;The Katmai CTP goes public today. The download hasn&amp;#39;t appeared on Connect yet but the link is here:&lt;br /&gt;&lt;a href="http://connect.microsoft.com/sqlserver"&gt;http://connect.microsoft.com/sqlserver&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Microsoft is previewing&amp;nbsp;Katmai at TechEd and there is also a webcast you can join from the TechEd site:&lt;br /&gt;&lt;a href="http://www.microsoft.com/events/series/teched07.aspx"&gt;http://www.microsoft.com/events/series/teched07.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=7135" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/Katmai/default.aspx">Katmai</category></item><item><title>Relational Futures</title><link>http://consultingblogs.emc.com/davidportas/archive/2007/05/23/Relational-Futures.aspx</link><pubDate>Wed, 23 May 2007 06:49:00 GMT</pubDate><guid isPermaLink="false">e847c0e7-38d9-45c0-b593-56747303e088:7037</guid><dc:creator>David.Portas</dc:creator><slash:comments>0</slash:comments><comments>http://consultingblogs.emc.com/davidportas/comments/7037.aspx</comments><wfw:commentRss>http://consultingblogs.emc.com/davidportas/commentrss.aspx?PostID=7037</wfw:commentRss><description>&lt;p&gt;&lt;em&gt;Alice: What do you mean by practical languages?&lt;br /&gt;Riccardo: select from where.&lt;br /&gt;Alice: That&amp;#39;s it?&lt;br /&gt;Vittorio: Well, there are of course lots of bells and whistles.&lt;br /&gt;Sergio: But basically, this forms the core of most practical languages.&lt;/em&gt;&amp;nbsp;[1]&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Oracle is celebrating its &lt;a href="http://www.oracle.com/oramag/profit/07-may/p27anniv.html" title="Oracle 30th Anniversary"&gt;30th birthday&lt;/a&gt; this month. They didn&amp;#39;t adopt Oracle as the company name until 1982, before which they were known as Relational Software Inc. Of course their very excellent, landmark database product is also &amp;quot;relational&amp;quot; by name and reputation but strictly &lt;em&gt;non-relational&lt;/em&gt; in fact. All SQL DBMSs borrow certain features and terminology of the relational model while remaining fundamentally anti-relational in many important respects[2]. IBM&amp;nbsp;began by&amp;nbsp;declaring that its SQL language was in fact &amp;quot;relational&amp;quot; and the name has stuck.&lt;/p&gt;&lt;p&gt;Once or twice I have floated the idea that a new relational database language should be added to SQL Server as an alternative to the T-SQL language. In my opinion the time is right for it. SQL Server already has several data access languages and layers of abstraction - such as SSAS/MDX, LINQ, SSIS - so adding another one isn&amp;#39;t exactly a radical idea. What I&amp;#39;m talking about would be a relational language that lives up to Date and Darwen&amp;#39;s &lt;a href="http://acm.org/sigmod/record/issues/9503/manifesto.ps" title="The Third Manifesto"&gt;description&lt;/a&gt; of a &amp;quot;D&amp;quot; language.&lt;/p&gt;&lt;p&gt;Naturally the new language would imply a new data model as well - the relational data model instead of the SQL one - but I don&amp;#39;t think it would be difficult to build it on top of SQL Server&amp;#39;s existing engine. In fact one of the key benefits would be that the engine could be freed of certain restrictions imposed by SQL (for example the requirement to support duplicates and column order). Implementing a new language would be a much more modest step than it was to add the OLAP Services engine into SQL Server 7.0 back in 1998.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;I was recently asked for some examples of problems solved by a true RDBMS that aren&amp;#39;t solved already by SQL Server (or other SQL DBMSs for that matter). A full list would be pretty long! Among other things an RDBMS would deliver a truly unified model suitable for both OLTP and OLAP applications. Performance and storage improvements due to better data independence. Support for declarative constraint logic. A more powerful and generic type system.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;A relational language would also fix some of the more irritating limitations that waste so much SQL programming time today. Duplicate rows and the consequent failure to support guaranteed access. No relational assignment or comparison operators. No multiple assignment. Three-value logic.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;Is it going to happen? I don&amp;#39;t know, but I do think the combination of today&amp;#39;s business demands and today&amp;#39;s technology make it a real possibility - perhaps more so than at any time in the last 30 years. SQL was a data access language for the 1980&amp;#39;s but a 21st century replacement is well overdue. Comments and feeback are welcome!&lt;/p&gt;&lt;p&gt;--&lt;/p&gt;&lt;p&gt;[1] From &amp;quot;Foundations of Databases&amp;quot;, Chapter 7, by Abiteboul, Hull and Vianu. Addison-Wesley&lt;/p&gt;&lt;p&gt;[2] There are numerous references that cover the details. I can recommend &amp;quot;Database in Depth&amp;quot; by Chris Date. &amp;quot;The Askew Wall&amp;quot; by Hugh Darwen, republished in &amp;quot;Relational Database Writings 1989-1991&amp;quot;&amp;nbsp;explains the origins of SQL and some of its limitations.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://consultingblogs.emc.com/aggbug.aspx?PostID=7037" width="1" height="1"&gt;</description><category domain="http://consultingblogs.emc.com/davidportas/archive/tags/SQL/default.aspx">SQL</category></item></channel></rss>