Daily Archives: July 22, 2010

How to create bootable VHD – Windows 7 or Windows 2008 R2

 

The below steps shows how to create a bootable VHD install for Windows 7 or Windows 2008 R2. With this step x64 OS can be installed, but requires a VT enabled machine in the BIOS.

1. Insert the Bootable Install DVD to the drive[Windows 7 or Windows 2008 R2]

2. Restart the machine, make sure the boot order is to DVD first in the BIOS to boot in DVD.

3. Once the windows is loaded, Select next in the Language selection screen

4. In the Install Now screen, Press Shift+F10 to enter into the command prompt

5. Type Diskpart and Enter

6. Type Create vdisk file=”c:\vhd\win7x64.vhd” type=expandable maximum=<vhd size in MB>

7. For differencing vhd shd add the parent=”VHD path” in the above command (optional)

8. Press Enter and Type Select vdisk file=”c:\vhd\win7x64.vhd”

9. Type attach vdisk

10. Press Alt+Tab

11. Now click on the Install Now Button

12. In the Drives windows select the virtual disk which we created, usually will be at the last. Ignore the warning which appears at the bottom.

13. Done, then follow the wizard to finish installation.

XSD.exe Class Generate Error – Datatype missing for sqltypes

 

Select *  FROM dbo.aspnet_applications  FOR XML AUTO, XMLSCHEMA

The xsd generated from sql using the following query(aspnet_applications is the table name) will have the sqltypes imported in the schema. If we use the xsd command line tool to generate a cs class the xsd will through the exception

Error: Error generating classes for schema ‘aspnet_applications’.
  – The datatype ‘
http://schemas.microsoft.com/sqlserver/2004/sqltypes:nvarchar’
is missing.”

If we look at the xsd generated by sql the namespace will point to the sqltypes.xsd uri which xsd.exe could not resolve.

—————–XSD Generated By SQL ————–

<xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:schema="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
  <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
  <xsd:element name="AETSMiMgmtDev.dbo.aspnet_Applications">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="LoweredApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="ApplicationId" type="sqltypes:uniqueidentifier" />
        <xsd:element name="Description" minOccurs="0">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

———————END——————

To solve this issue i modified the xsd to include the xsd in the local directory. I navigated to the URL “http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd” , downloaded the full xsd and saved the file as sqltypes.xsd

After saving the sqltypes in a seperate xsd, i modified the original aspnet_applications.xsd like below

—————–Modified XSD to work for xsd.exe————

<xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" xmlns="Subscribers"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes"
            elementFormDefault="qualified">
  <xsd:include schemaLocation="sqltypes.xsd" />
  <xsd:element name="aspnet_Applications">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="LoweredApplicationName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
        <xsd:element name="ApplicationId" type="sqltypes:uniqueidentifier" />
        <xsd:element name="Description" minOccurs="0">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreNonSpace IgnoreKanaType IgnoreWidth">
              <xsd:maxLength value="256" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

——————————END————-

The modified tag is in red bold color. Remember the downloaded sqltypes.xsd is in the same directory as the aspnet_applications.xsd
Now if we run xsd.exe aspnet_applications.xsd /c

the class generation will be successful