# Tuesday, February 26, 2008

The SQL Server 2008 February CTP is now installed. I did it on my daily machine to force me to use it in a more realistic environment. It installed a-ok with my default SQL 2005 instance. As you can see below you can use the SQL 2008 IDE to manage and work with both SQL Server instances on your computer at the same time.

image

I am playing with the new XML features of SQL Server. For those of you that know my old company, Corzen, used the XML data type to do some really cool stuff. I'm now investigating the XML features for the update to the Programming SQL Server 2008 book from MS Press.

I guess that XLINQ is pretty cool and well accepted Microsoft did not change all that much in the XML world in SQL Server 2008. The new XML features of SQL Server 2008 are:

  • Lax validation support in XSD-giving you some more flexibility with your required areas of the XSD
  • Full support of the XSD: xs:dateTime, basically the preservation of time zones
  • Union and List types in XSDs (I have not played with this yet so can't speak to how useful it will be yet, give me a day)
  • Support of the LET FLOWR expression in XQuery (yay!)
  • XML DML "enhancements." I put that in quotes for two reasons, there is only one true enhancement, allowing you to insert data from a SQL column or a SQL variable as part of your insert. This is a very minor enhancement, I was hoping for a new syntax for specifying position, etc. Also XML DML is SQL Server specific, so it is hard to get very excited about this feature.

Now let's take a look at some of the XSD enhancements. SQL Server 2005 added the ability put XML data into an intrinsic XML data type. This was a vast improvement over SQL Server 2000 where we had to put data in text fields. In addition, SQL Server 2005 allowed us to restrict this column with an XSD. Consider this XSD:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:simpleType name="orderAmt" >
     <xsd:restriction base="xsd:int" >
       <xsd:maxInclusive value="5000" />
       <xsd:minExclusive value="1" />
     </xsd:restriction>
   </xsd:simpleType>
   <xsd:element name="Order">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="CustomerName" type="xsd:string" />
        <xsd:element name="OrderDate" type="xsd:dateTime"/>
        <xsd:element name="OrderAmt" type="orderAmt"/>
      </xsd:sequence>
    </xsd:complexType>
   </xsd:element> 
</xsd:schema>

We have defined a few elements, given them a sequence and data types. We also say that you can only have an order amount between 1 and 5000 (work with me, I like simple demos) since the OrderAmt element inherits the simple type orderAmt. This works well, for example if we create an XSD and a table with an XML column bound to that XSD in SQL 2005:

--Valid SQL Server 2005 Schema
CREATE XML SCHEMA COLLECTION dbo.order_xsd
AS
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:simpleType name="orderAmt" >
     <xsd:restriction base="xsd:int" >
       <xsd:maxInclusive value="5000" />
       <xsd:minExclusive value="1" />
     </xsd:restriction>
   </xsd:simpleType>
   <xsd:element name="Order">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="CustomerName" type="xsd:string" />
        <xsd:element name="OrderDate" type="xsd:dateTime"/>
        <xsd:element name="OrderAmt" type="orderAmt"/>
      </xsd:sequence>
    </xsd:complexType>
   </xsd:element> 
</xsd:schema>'
GO

CREATE TABLE xml_schematest (
   Order_ID int primary key,
   Order_XML XML(order_xsd) --XML Schema Name
)

Now let's insert some XML in there, the XML will be like this:

Insert into xml_schematest
VALUES
(1,
'<Order>  
    <CustomerName>Bill Gates</CustomerName>
    <OrderDate>2008-10-10T14:22:27.25-05:00</OrderDate>
    <OrderAmt>100</OrderAmt>
</Order>
')

Here is the result, notice the Z for UTC as well as the new time (more on that below):

<Order>
  <CustomerName>Bill Gates</CustomerName>
  <OrderDate>2008-10-10T19:22:27.250Z</OrderDate>
  <OrderAmt>100</OrderAmt>
</Order>

This XML will fail since it has an order over 5000.

Insert into xml_schematest
VALUES
(2,
'<Order>  
    <CustomerName>Bill Gates</CustomerName>
    <OrderDate>2008-10-10T14:22:27.25-05:00</OrderDate>
    <OrderAmt>10000</OrderAmt>
</Order>
')

So life is good. We have a nice XSD and it restricts our content. SQL Server 2008 has added two new features of an XSD that we will look at today. The first is something called Lax validation. Let's say that you wanted to add an additional element after <OrderAmt> that is not part of the same schema. In SQL Server 2005, schemas can use processContents values of skip and strict for any and anyAttribute declarations as a wildcard. If it was set to skip, SQL will skip completely the validation of the additional element, if it is set to strict, SQL will require that it has an element or namespace defined in the current schema. SQL Server 2008 adds support for an additional validation option: lax. By setting the processContents attribute for this wildcard section to lax, you can enforce validation for any elements that have a schema associated with them, but ignore any elements that are not defined in the schema. Pretty cool, no?

Also the xsd:dateTime XML data type is now timezone aware. SQL Server 2005 you had to provide a time zone for dateTime, time and date data (did you really ever do that? If you needed the flexibility, trust me, this was a pain). What was not cool was that SQL Server 2005 did not preserve the time zone information for your data for dateTime or time,  it normalizes it to UTC (so for example 2008-10-10T08:00:00:000-5:00 is normalized to 2008-10-10T13:00:00:000Z. Notice the Z for UTC. Quite annoying.) In SQL Server 2008, this has been removed! Take a look at this code:

CREATE XML SCHEMA COLLECTION dbo.order_xsd
AS
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:simpleType name="orderAmt" >
     <xsd:restriction base="xsd:int" >
       <xsd:maxInclusive value="5000" />
       <xsd:minExclusive value="1" />
     </xsd:restriction>
   </xsd:simpleType>
   <xsd:element name="Order">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="CustomerName" type="xsd:string" />
        <xsd:element name="OrderDate" type="xsd:dateTime"/>
        <xsd:element name="OrderAmt" type="orderAmt"/>   
        <xsd:any namespace="##other" processContents="lax"/>   
      </xsd:sequence>
    </xsd:complexType>
   </xsd:element> 
</xsd:schema>'
GO
CREATE TABLE xml_schematest (
   Order_ID int primary key,
   Order_XML XML(order_xsd) --XML Schema Name
)
GO

Now this will work and even preserve the time zone of -5 (New York) and notice the random <Notes> element due to lax validation. Here is how to insert the XML:

Insert into xml_schematest
VALUES
(1,
'<Order>  
    <CustomerName>Bill Gates</CustomerName>
    <OrderDate>2008-10-10T14:22:27.25-05:00</OrderDate>
    <OrderAmt>100</OrderAmt>
    <Notes xmlns="sf">Steve Test 1</Notes>
</Order>
')

Here are the results in the database with the original time zone:

<Order>
  <CustomerName>Bill Gates</CustomerName>
  <OrderDate>2008-10-10T14:22:27.25-05:00</OrderDate>
  <OrderAmt>100</OrderAmt>
  <Notes xmlns="sf">Steve Test 1</Notes>
</Order>

Tomorrow I will look at Union and List types.

posted on Tuesday, February 26, 2008 12:00:36 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, February 25, 2008

Google's co-founder Sergey Brin said on Sunday that Microsoft's proposed takeover of Yahoo! is an "unnerving" maneuver that threatens innovation on the Internet. Brin stated:

"The Internet has evolved from open standards, having a diversity of companies... And when you start to have companies that control the operating system, control the browsers, they really tie up the top Web sites, and can be used to manipulate stuff in various ways. I think that's unnerving."

Get a grip Sergey. This sort of scare tactic could have worked 10 years ago before Web 2.0 and before there was a serious threat to Microsoft on the Internet called Google. Google is a huge company that has an over 70% market share. Microsoft has a tiny market share, even with the combined Yahoo, Microsoft-Yahoo will still be very far behind Google.

Microsoft's hold on the desktop and browser for the last 10 years has not made it any more powerful in the 2008 Web 2.0 world. They are distant third place in search and losing ground. They are no longer the evil empire.

Google is the new evil empire. They are big, they control a ton of eyeballs and many people in the valley are now saying that Google is very difficult to deal with. Microsoft is just another player in the Internet space, Google is bringing up old battle cry's from yesteryear. Sergey better watch out, the Department of Justice may just come after him in a few years. Don't think so? Bill Gates never thought so.

posted on Monday, February 25, 2008 10:32:11 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, February 22, 2008

It was my birthday on Wednesday and we decided to go to the Pyramids with all of the investors of DashSoft as well as the entire team of local Egyptians. There is nothing like going to the Pyramids with locals. But the adventure started before we even got there.

Riding a taxi in Cairo is always an adventure. The adventure starts before you get into the taxi, when you have to negotiate the fair. Vassil was the butt of our jokes since he paid LE 90 (about $17) to get from the hotel to the office on Monday when we paid about LE 15 ($2.75). Vassil is not the best negotiator but desperately wanted to make amends. We got the inside scoop from the locals that it should cost no more than LE 35 from our hotel to the Pyramids. I warned Vassil that the taxi driver may start at LE 200 and he will have to knock him down. Vassil asked the first taxi for a price and the taxi started at LE 50 and Vassil immediately said 40, not something like 5! Oh well....

As we rode through Cairo, we were due to meet Remon at the Pyramids. He was traveling with the whole team of developers and testers from the office. All of the developers have been to the Pyramids just once in their lives and it was on a school trip. Remon rented a bus, a bus we were not on.

Back in the taxis, Vassil was filming me practicing my Arabic with the drivers of other cars since we were stuck in traffic. After we got to the highway we lost the third taxi in our caravan, holding Richard Campbell and his wife and friend Mike. Our taxi driver phones Richard's taxi and we pull over to the slow lane  of the highway and stop and wait for them. I decide to get out and have some fun. I tell my taxi drivers I want to buy my taxi. They start to compete saying who's taxi is better. The fun got even better when a random third taxi appeared and thought we were broken down (I was taking photos of the taxis) and when I explained to him that I was attempting to buy a taxi, he offered his. I had him down to about $700.  My driver then shooed him away. Finally Richard's taxi drove by and the look on their faces was priceless, I was walking around on the highway taking photos and they did not expect to see me. Oddly enough, Remon's van passed us by and Reem noticed me on the side of the road taking photos and joking with the taxi drivers. So they pulled over and picked us up. We paid our taxi drivers and took their photos and left for the Pyramids.

IMG_0809a

Entering the Pyramids you learn that it costs LE 100 ($20) for a foreigner to enter the Pyramids and LE 4 (< $1) for an Egyptian! I pose for a photo with my Egyptian wife Lamees and try to pass myself off as an Egyptian to no avail. I did show my student photo from my MBA program and pay the LE 50 student rate.

IMG_0817a

We enter the grounds and go inside the Great Pyramid. Unfortunately no cameras are allowed inside and we climb up to the room where the king's body and gold was stored. After climbing up for 15 minutes in the heat and no oxygen, we finally get there. It is an empty room. But a 4,000 year old empty room. Very cool.

We get down and then start having more fun. We take tons of silly photos. The Egyptians were just as excited as us foreigners.

IMG_0834a

Next we move on to the camels. Yes camels. What kind of trip to the Pyramids would be complete without camels?!?! I have been to the Pyramids about 7 or 8 times so I do not ride a camel but take tons of photos.

IMG_0854a

We then move to the Sun-Boat museum where the Pharaoh's boat is stored.  The admission fee is LE 40 and I once again try to pass myself off as Egyptian. The best I can do is say I am the professor of all of the locals with me, Lamees gives the man her Student ID card and we buy 10 local student passes (LE 20) and one foreigner student pass (LE 20) and go inside. One foreigner costs the same as 10 locals! We meet up with Richard who I instruct to call me Professor.

IMG_0892a

Next we drive in the bus to the paranoiac view point of all three main Giza Pyramids. We take a team photo.

IMG_0896a

The locals want to ride horses down to the Sphinx. Most of us get on a horse but some are afraid or want to ride a camel. Some are just plain old boring and take the bus down. (Richard and his crew.) The camel/horse guy double crosses Michael (the local who negotiated the deal) and we are taken down to the Sphinx and then back to where we started. So we take the bus down to the Sphinx to meet Richard and crew.

IMG_0932a

By now we have been at the Pyramids for about 5 hours and are hungry for lunch. There is a Pizza Hut right across from the Sphinx. I say "let go in there!" and our only dissenter is Remi who says "I can get Pizza Hut in the Netherlands but not Falafel." The locals really want American fast food, who can blame them! I tell Remi that I can get falafel in New York, but not Pizza Hut. (True) So we split up and get some Pizza Hut. The view of the Sphinx inside of Pizza Hut is awe inspiring and my photos are better then outside due to the height of the second floor.

IMG_0943a

After hanging out and shooting the breeze we take the bus back to the hotel, which contains the largest shopping mall in the Middle East and shop. I decide to hang out in Starbucks and wait for the girls.

We then depart for the Nile where Remon has arranged a boat ride, dinner, and birthday cake as well as Arabic music and dancing. It is a full moon and we cruse along the Nile for a few hours, eating, dancing and having a blast. Several happy birthday chants were sung in both English and Arabic. 

We head back to the hotel, have a drink and pass out. It sure has been an interesting 36 years so far.

PS: flickr photos are here.

posted on Friday, February 22, 2008 10:21:09 AM (Eastern Standard Time, UTC-05:00)  #    Comments [2] Trackback
# Tuesday, February 19, 2008

Today Toshiba announced the death of HD DVD saying that it will no longer produce HD DVD players. While a standards war between Toshiba's HD DVD and SONY's Blu-Ray was in full swing, Blu-Ray emerged today as the winner. The death of HD DVD was very quick, here is how it happened:

  • Popularity of SONY Playstation 3 at Christmas
  • Warner Brothers pulling out of the format leading to limited Selection of HD DVDs titles
  • Netflix going Blu-Ray exclusive

I think the tipping point was Netflix going exclusive. With Warner Brothers out and Paramount rumored, the writing was on the wall. It took 8 days from the Netflix announcement to the actual tossing in of the towel by Toshiba. Score one for the power of the people. Once Netflix spoke on behalf of its members, HD DVD died.

Blu-ray will have to compete hard against high-def Internet downloads. With a lot of the public not willing to pay over $30 for a new Blu-ray disk movie (compared to a $10 DVD) and new players being expensive;  hard drive space being super cheap and broadband also ubiquitous and cheap, Blu-ray will have a major fight on its hands. Expect a repeat of the MP3 Napster debate from 10 years ago.

Business models will have to change. Will the movie/DVD industry learn anything from the music/CD industry? I doubt it.

posted on Tuesday, February 19, 2008 5:12:05 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Wednesday, February 13, 2008

According to the Alley Insider, Yahoo's second largest shareholder, investor firm Legg Mason, has met with Steve Ballmer and supports a bump in the price and thinks that Yahoo should take it. Legg Mason outlined in a letter to shareholders that Microsoft will offer better value than Yahoo can deliver on its own. If you remember Microsoft offered $36 last summer. Expect them to go at least this high, if not higher. (They most likely were prepared to pay this high already.) The Google-Yahoo deal has went cold according to the Wall Street Journal, so Yahoo has very little in the way of options.

Brilliant strategy by Microsoft. Come in at a low point when Yahoo is laying off 1,000 workers with a low bid. Get the shareholders excited, have the board reject the offer and then up the bid. Not the board of directors is stuck between a rock and a hard place. Or between a Google and a Microsoft.

When it looks like this deal will go through, I will post why I am such a strong supported of it and counter all the anti-deal.

posted on Wednesday, February 13, 2008 8:03:41 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, February 12, 2008

Over the weekend Yahoo! board members leaked to the Wall Street Journal that they felt that the Microsoft bid of $31 a share is "massively undervalued." Yahoo then officially rejected Microsoft's bid on Monday. What happened is that Yahoo's management convinced the board of directors not to sell at $31. But Yahoo shareholders want to earn that $31 or more. So Yahoo said the offer was "massively undervalued" and that $40 is what they want. Microsoft responded by saying that $31 is a full and fair deal and that Yahoo's counter offer of $40 is "Absurdly High." This is the classic negotiation tactic know as anchoring.

Microsoft is not backing down. Steve Ballmer said he is willing to go higher. Negotiation statistics say that in cases like this firms usually "split the difference" and would settle for around $35 a share. But Microsoft is also pulling no stops, they are hiring a proxy firm to start a hostile takeover. This is knows as Microsoft's BATNA or "best alternative to a negotiated agreement." It is the stick to the upping the price carrot.

Microsoft is offering Yahoo a solid premium over its true valuation. Since there are no other bidders and Yahoo's financial position is weak at the moment, Yahoo has very little leverage. Yahoo's only other option (BATNA) is to have massive layoffs (some scenarios put it at 33% of the company) and potentially outsource search and advertising to Google. (We all saw how that worked for AOL, moving from 20% to 5%.) Actually according to the Alley Insider, Microsoft's premium is rather large: RBC's Jordan Rohan has said: Yahoo is valued at about $24. That would put Microsoft's bid at an approximately 30% premium. Shareholders like 30% premiums. They also don't like when board of directors let pride get in the way of a fail deal to earn 30% on their money (epically with the Dow down 14% this year.) They tend to have shareholder revolts when board of directors do that. Microsoft is already talking to large investors to get them on their side. According to the Alley Insider:

  • Mutual fund giant T. Rowe Price, which owns 18 million shares of Yahoo! said yesterday that it would be "very vocal" if Microsoft raises its offer and Yahoo! rejects it again.
  • Capital Research and Management, Yahoo!'s largest investor with a recently raised stake of 11.6 percent, is said to favor a deal as well.

Once again, my prediction is that the deal will go through. Yahoo has nowhere to turn. Its large shareholders are going to be angry if the board rejects another offer. Microsoft has to fight the new evil empire Google and will up the ante. This is going to be fun to watch.

posted on Tuesday, February 12, 2008 11:13:31 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Friday, February 8, 2008

Yahoo!'s board of directors is to meet today to decide the fate of the company. There is a lack of an alternative suitor since the only viable one, Softbank, bailed out today. Microsoft CEO Steve Ballmer said in Business Week that the Yahoo! brand will "live on" which means the death of MSN and possible the Live! brand as well.

Yahoo!'s only other option is a deal with Google and try to stay independent. They would have outsource the search and ad functionality to Google and shut down that operation, laying off thousands (some estimates are 33% or more of the company) and focusing on the portal/content side of the business.

AOL did that. It did not work out well for them, they lost drastic market share and have never recovered. If Yahoo! did the same and lost market share, then they would be ceding eyeballs to Google.

My gut tells me that Yahoo! is not going to make the same mistake twice. It is Yahoo! that put Google on the map. Yahoo! outsourced their search to Google in the early days of Google and Google eventually took all the market share away. Why would all those smart people make the same mistake twice? My gut tells me that Ballmer has assured them of independence and they will swallow their pride and take the deal.

As a Microsoft watcher, I am excited about the deal. Here is my message to Microsoft: Don't mess this up! The whole world is watching. Microsoft is the "evil empire" in Silicon Valley. Everyone hates Microsoft there. If Microsoft handles Yahoo! right it is a historic opportunity for Microsoft to win the hearts and minds of the Valley. If they mess up the brand (think of this: Microsoft Yahoo! MSN Live! Messenger for Workgroups Professional Edition 2008 Service Pack 2a) and come in all arrogant and have tremendous layoffs, then why bother? If Microsoft handles this in a great way and wins over the hearts and minds of Yahoo! employees (who all hate Microsoft) then it is the first step in repositioning itself in the Valley. The new new evil empire in the Valley will be Google.

posted on Friday, February 8, 2008 10:46:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, February 7, 2008

Let’s say that you are an American software company and are doing some custom consulting work for a company in the UK. They agree to pay you £ 1,000,000 in six months when you deliver the source code. (Great work if you can get it!)

Today the £ is trading at: $1.9438/£, this means that each £1 will get you US $1.94. This puts the value of your contract at $1,943,800. So we have seen the US dollar fall over the last few years and you want to protect yourself against fluctuations. If the dollar gains 10% for example in six months, you will get less dollars in six months when the UK company pays you. You want to lock into today's exchange rate.

There are many ways to do it, but here is a cool one. According to today’s WSJ, the UK prime rate is 5.5%. In the US, E*Trade’s 6 month CD rate is 3.38%.

So what do you do? Borrow £ and invest them in $. Here is what you do in specifics:

You know you are going to have a payment of £ 1,000,000 in six months. So take out a 6 month loan in the UK which you will pay back with your £ 1,000,000 payment.

How much of a loan? Not £ 1,000,000. But £ 1,000,000 minus the interest you will pay. You find that like this:

The UK prime rate is 5.5% per year. You will borrow for 6 months. So 5.5/2= 2.75%. (You divide by 2 since you are doing it for 6 months of ½ a year. If it was for 3 months you would divide by 4.)

Now get the 2.75% to a multiplier, so 1 + (2.75/100)= 1.0275

So £ 1,000,000 / 1.0275 = £ 973,236

So you will borrow £ 973,236. In six months you will owe £ 1,000,000.

Now take that £ 973,236 and convert it to US dollars.

£ 973,236 x $1.9438/£= $1,891,776.16

Now invest that in your E*Trade 6 month CD at 3.38% (We don’t have to divide by 2 since this is the published rate for 6 months, E*Trade did the math for us.)

Now get the 3.38% multiplier, so 1 + (3.38/100)=1.0338

In 6 months you will receive: $1,891,776.16 x 1.0338=$1,955,718.19

When you have to pay off your loan in six months in the UK, it is £ 1,000,000, just hand over your £ 1,000,000 check your customer gives you. Who cares what the £ is trading at-up or down. You also made about $12,000 over your estimate of $1,943,800 by investing the money at a higher annual rate (closer to 6% than your borrowed at 5.5%). Of course you will have to pay taxes on this amount but then again you can deduct the interest on your taxes of the UK loan!

Now, let's return in 6 months and see if the £ went up or down against the $!

posted on Thursday, February 7, 2008 10:26:28 AM (Eastern Standard Time, UTC-05:00)  #    Comments [2] Trackback