# Monday, May 10, 2004

Today I gave software developers in the Netherlands a preview of the XML Features of SQL Server 2005 or better know by its code name “Yukon” (the US National Park, not the Canadian frozen land). I show off the very cool and advanced XML to Relational mapping. (Clemens is a big fan). I then talk all about the deep XML integration via the XML Data type. This is a native SQL Server type so we have the option to store XML in its native format. For example you can do just about anything a standard datatype can do, excluding Foreign Keys and PKs. Here is the XML Data Type at work in a variable:



SET @xmlData = (SELECT * From Customers where CustomerID='ALFKI'  FOR XML AUTO, TYPE)

SELECT @xmlData


The results look like this:

<Customers CustomerID="ALFKI" CompanyName="Alfreds Futterkiste" ContactName="Maria Anders" ContactTitle="Sales Representative" Address="Obere Str. 57" City="Berlin" PostalCode="12209" Country="Germany" Phone="030-0074321" Fax="030-0076545"/>


(1 row(s) affected)


Then it is fun to create tables with XML fields in them and do things like create an index on them, etc.

--create the table with the XML Datatype




Then you can insert some XML into the table, you can do this manually, from an XML Raw statement or via a XML file.

--Get some XML Data, can also use a file


SET @xmlData = (SELECT * From Orders FOR XML AUTO, TYPE)


--insert into the table

Insert Into OrdersXML (OrderDocID, xOrders) Values (1, @xmlData)


Then let’s add an index on that column:

CREATE XML INDEX idx_1 ON OrdersXML (xOrders)


It is more fun to create an XML Schema as data validation for data validation. This is my favorite thing about the XML integration, it gives you the best of both worlds. This shows off the deep integration of the XML model and the relational model, the XML Schema works just like a constraint, allowing us to validate the XML that we put into our XML data type fields in the database.


--xml schema as validation

use northwind


'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"


            targetNamespace="http://corzen.com/customer" >

   <xsd:simpleType name="personAge" >

     <xsd:restriction base="xsd:float" >

       <xsd:maxInclusive value="65" />

       <xsd:minExclusive value="18" />



   <xsd:element name="age" type="tns:personAge" />




-- create table with xml column and use schema as a 'constraint'

CREATE TABLE xml_schematest (

   the_id INTEGER,

   xml_col XML('http://corzen.com/customer')




-- works

INSERT INTO xml_schematest VALUES(1,

 '<p:age xmlns:p="http://corzen.com/customer">55</p:age>')



-- fails, age > 65

INSERT INTO xml_schematest VALUES(2,

 '<p:age xmlns:p="http://corzen.com/customer">100</p:age>')



-- fails, column is validated on update also

UPDATE xml_schematest

  SET xml_col = '<p:age xmlns:p="http://corzen.com/customer">100</p:age>'

  WHERE the_id = 1


DROP TABLE xml_schematest



DROP XMLSCHEMA NAMESPACE 'http://corzen.com/customer'




But wait, there’s more! I show off a little bit of XQuery. What is cool is that XQuery is integrated fully with TSQL.



use adventureworks

--take a look at an XML column

select * from ProductModel where productmodelid=19


--query out a piece of data from the xml field

SELECT Name, CatalogDescription::query('

namespace PD="http://www.adventure-works.com/schemas/products/description"

<Product ProductModelID="{ /PD:ProductDescription[1]/@ProductModelID }" />

') as Result


FROM ProductModel


where Name like 'Mo%' and CatalogDescription::exist('

namespace PD="http://www.adventure-works.com/schemas/products/description"

namespace wm="http://www.adventure-works.com/schemas/products/WarrAndMain"

     /PD:ProductDescription/PD:Features/wm:Warranty ') = 1



posted on Monday, May 10, 2004 3:45:37 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Friday, May 7, 2004

I am leaving tomorrow for the Netherlands to speak at the Software Developers Conference in Arnhem, the Netherlands. What was once CTTM is now SDC, so I have been doing this conference every year since 1998. my sessions are:


-          Exploring the XML Features of SQL Server “Yukon

-          ASP .NET Scalability- Caching Techniques


Also I rejoin my pal and now fellow RD Richard Campbell on stage for a Joint session:

-          From Interoperability to Migration: SQL Server and Linux Databases Working Together


Besides Richard and I other RDs will be there, Clemens, Michelle, Gert, Paul Sheriff, and Ken Getz.


Look forward to seeing you there!



posted on Friday, May 7, 2004 12:44:26 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [5] Trackback
# Thursday, May 6, 2004

Major League Baseball is going to decorate the bases one weekend with Spiderman web logos as part of a promotion for the new Spiderman 2 movie. People are complaining that there is too much advertising. Or it is “destroying the sacred game.” Ok, the madness has to stop. There have been billboards in the outfield of stadiums since the 1800s. Wrigley Field, one of the last legends, like 100 years old was the fist field named after a corporate sponsor and nobody seems to care in Chicago about that one. (And the proves that sponsorship works, ask anyone where the Cubs play and Wrigley has free advertising based on money they spent 100 years ago, how is that for ROI.)


Other sports sell ads. Ever watch the World Cup? The Olympics? Or my beloved hockey, where the NHL allows the stadiums (with names like Pepsi Arena) to sell ads under the ice. Or what about the Baseball teams in Japan, named after corporate sponsors.


Let’s face it, we live in a world ruled by advertising and corporate sponsorship. Just deal. Critics of the game should be more concerned with all the players on Steroids.

posted on Thursday, May 6, 2004 12:04:59 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [20] Trackback
# Monday, May 3, 2004

Yesterday’s 27th Annual 5 Borough Tour started out with a little bit of rain, but it turned out to be a very awesome day. We rode our bikes over 42 miles with the streets closed to cars from Battery Park, pass ground zero, up 6th Avenue into Central Park and then Harlem into the Bronx, back down the FDR in Manhattan to the 59th Street Bridge, through Queens and Brooklyn and finally the winds died down as we climbed the 2.5 mile span of the Verrazano Narrows Bridge (the longest suspension bridge in the US) into Staten Island.


I have done this ride every year except two since 1986. If you like to bike ride and live in New York City.

posted on Monday, May 3, 2004 9:56:57 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [19] Trackback
# Friday, April 30, 2004

First of all, I wish Google all the success in the world in its IPO, I hope it makes tons of money for the company, shareholders and its founders, they deserve it. I love when the free market rewards entrepreneurs. Google is the best damn place on the Internet, period. I have it as my home page and use the Google Toolbar extensively.


That said, I will not buy the IPO shares. Google is valued at 20 to 25 billion dollars. I don’t know how that happened because until yesterday, Google’s revenues were a total mystery to the entire planet except to their CFO and the Venture Capitalists Kleiner Perkins who invested in Google a while back (and also invested in my company four years ago).


I read the public S1 filing document today. Google’s revenue was just under a billion dollars last year. We can do the math, 25x revenues is super overvalued. So let’s look at earnings. Last year Google had $343 million of operating costs (you think a server farm of a gazillion servers is cheap?) so its valuation is at 73x earnings. That is crazy talk.


Sure Google can grow. This year they are projected to grow by more than 50%, but of course operating costs will actually double. They are projected to have revenues of $1.6 billion and operating costs with $620 million that will put earnings at about a billion. That sounds like a huge jump in one year, but hey they do have a kick-ass product. Even so, 25x earnings is still an overvalued stock, no matter how you look at it.


You know what this sounds like to me? The late 90s internet bubble. So let the buyer beware.

posted on Friday, April 30, 2004 11:30:15 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [6] Trackback
# Thursday, April 29, 2004

I am officially boycotting the US Postal Service after they dropped their sponsorship of Lance Armstrong. Like 5 tours is not enough? I am sure that someone will pony up the money for the greatest team in pro cycling.

Just a few days ago Lance won the Tour of Georgia, a 1,000 km stage race. Next stop, a 6th Tour de France victory in July.

posted on Thursday, April 29, 2004 10:22:38 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [13] Trackback
# Wednesday, April 28, 2004

See you in Karachi June 15-17!

posted on Wednesday, April 28, 2004 4:36:24 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [16] Trackback
# Tuesday, April 27, 2004

The most beautiful woman on the planet is single again, Halle Berry filed for divorce.

posted on Tuesday, April 27, 2004 10:03:17 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [5] Trackback