Tuesday, July 31, 2007

Now that Kim and Paul have each posted about it and even published some pictures, I guess its time for me to send out a heartfelt CONGRATULATIONS to them both on the occasion of their recent wedding last weekend. All the best in your upcoming life together!

In a seperate/related announcement, Paul announced that he'll be joining SQLskills at summer's end. Welcome, Paul, it will be fantastic to have you onboard!

Tuesday, July 31, 2007 7:35:40 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  | 

I saw Dan Jones' posting that the SQL Server 2008 July CTP (aka CTP4) was available on the Connect website. This one has some good things in it (like the new date/time datatypes as well as the hierarchyid data type) that should keep me busy for a while. There's much more new stuff than that, but the connect website has also the detalis.

One thing that is included that isn't intuatively obvious is ADO.NET client support. The Visual Studio Orcas Beta 2 release contained a new version (well, its still called version 2.0.50727, hmmm...) of System.Data.dll with support for the new date/time data types and also for table-valued parameters. The only problem was that it didn't even *connect* to CTP3 (there was a "network protocol" error). But it connects to the July CTP just fine. One things that not working in Orcas Beta 2 is SQLCLR projects against a SQL Server 2008 database, but typing CREATE ASSEMBLY is a small price to pay.

The new OLE DB provider and ODBC driver have been in place in the last CTP, but this is the first I've seen of .NET client functionality.

There are two items (listed in the readme file) that will not be in the SQL Server 2008 release. One is SQL Server Notification Services, which made its first appearence as an web release add-in to SQL Server 2000. Its not shipping in SQL Server 2008, and (some/most of) its functionality will eventually appear in Reporting Services. Another (removed from the installer) is a less-well known add-in that also debuted as a web release, SQLXML 4.0 (NOT to be confused with the XML data type, which is alive and well and has new xsd:date etc support). This used to be known as the SQLXML Web Release (V1,V2,V3) for SQL Server 2000 and SQLXML 4.0 (mostly) shipped "in the box" in SQL Server 2005. Some of its functionality was superceded by native XML and Web Services support in SQL Server 2005. It will be removed from the installer and shipped as a separate component instead, like all versions previous to version 4.0 were.

Tuesday, July 31, 2007 7:18:05 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  | 
Tuesday, July 17, 2007

When I'm not busy writing about SQL Server, I quite enjoy reading books about it that look at things from a different point of view. I've been catching up on my reading lately, but getting behind on my book reviews. So here's a few reviews I'd been meaning to write for some time. The authors asked that I review them on Amazon, but I don't like either giving out personal information just to do a book review (too intrusive) or the idea of anonymous reviews/fake personal information (too easy to "stack the deck"). So I'm reviewing them here.

SQL Server 2005 Practical Troubleshooting (multiple authors, edited by Ken Henderson)
  The is a superb book about internals, with each chapter written by a dev, a PSS support person, or a member of the Development Customer Support Advisory team. Who could ask for more of an insiders' view? Maybe I like internals a bit too much, but I keep coming back to this book again and again. My favorite chapters are ones detailing the query cache and the query processor. I was originally put off by the number of proofreading/editing mistakes, but its worth getting past that and concentrating on the content in a hurry. Some excellent troubleshooting utilities are provided as well. A must read.

Expert SQL Server 2005 Development (Adam Machanic, Hugi Kornelis, and Lara Rubbelke)
  I really wrote my "review" for this one on its cover, you'll need to buy the book to read that part. This is not an overview book, nor does it try to be comprehensive in its coverage, but it covers, in depth, topics that you'll see nowhere else. In amazing depth. Absolutely worth every minute you'll spend reading and working the examples.

Pro SQL Server 2005 Service Broker (Klaus Aschenbrenner)
  I haven't received my copy of this one yet, but read a number of chapters as a reviewer before time constraints overwhelmed me. Based on the material that I did review, it's well worth reading. If Roger Wolter's Service Broker book was the seminal treatise on the subject, Klaus expands on the topics and provides quite a few examples and use cases.

Happy reading...

Tuesday, July 17, 2007 1:16:14 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]  | 

In just over a month, I'll be at TechEd 2007 Hong Kong. I'll be delivering a preconference talk on (what else) SQL Server 2005 and a number of breakout sessions. Check the SQLskills Upcoming Events for more information. The folks in Hong Kong always put on an excellent show, and I'm very much looking forward to it. In addition, some of my old friends like Jon Flanders and Ron Jacobs will also be there. It should be a good time, stop by and say hi.

Tuesday, July 17, 2007 12:45:43 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  | 
Tuesday, July 10, 2007

SQL Server 2008 will contain an ANSI SQL standard MERGE statement with extensions. Listening to the webcast last Friday, there's a fairly straightforward way to describe how this works.

Let's go back to first principals. Relational databases support two ways to do UPDATE and DELETE; positioned updates and searched updates. In a positioned update, you open an updatable cursor over a set of rows, navigate to the row you want, and issue an "UPDATE...WHERE CURRENT OF" statement. The searched update (UPDATE foo SET x=y WHERE z=1) is a SELECT and UPDATE in one statement. You specify the rows you want and also update them. The way you specify/gather the rows to update is mostly up to you, SQL Server even supports using a JOIN to do this.

update t
set t.name = s.name, t.age  = s.age
from [target] t
join [source] s on t.id = s.id;
go

MERGE in SQL Server 2008 is a searched operation that can operate on up to three different rowsets depending on how you specify the MERGE statement. These are actually the three rowsets you can get from a FULL OUTER JOIN. The statement:

select [target] t
inner join [source] s on t.id = s.id;

gets the rows in table T with a matching id value in table S. Let's call this rowset1. A left outer join will also include the rows in T that do not match S (rowset2); right outer join includes the rows in T that don't match S (rowset3), and FULL OUTER JOIN contains all three rowsets.

In MERGE, you can get up to all three rowsets (INNER, LEFT, and RIGHT join rowsets)

merge [target] t
 using [source] s on t.id = s.id
 when matched then update t.name = s.name, t.age = s.age -- use "rowset1"
 when not matched then insert values(id,name,age) -- use "rowset2"
 when source not matched then delete; -- use "rowset3"

The query processor will do the appropriate type of join to gather the rowsets that you need, as all clauses are not required. This optimizes performance over multiple statements, as you only have to gather the rows to process once.

Even, if you use only "when matched", MERGE is an improvement over our first "update using a join". If more than one row in the source matches one row in the target...

insert into t values(1, 'Fred', 42)
insert into s values(1, 'Buddy', 43)
insert into s values(1, 'Sam', '95)

The update using a join non-deterministically picks a row in the source to do the update, it could be Buddy or Sam. MERGE throws the following exception.

Msg 8672, Level 16, State 1, Line 1
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.

MERGE can actually do more than three operations using predicates in the "match/no match clauses", but that's it for now.

Tuesday, July 10, 2007 7:42:55 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: