title: Add a lookup field to a content type in sharepoint
body: <p>How can I add a lookup field to a content type in sharepoint using the xml definition? (I'm getting errors).</p>
  
  <p>Things to note:
  - The lookup list will exist when the content type is added to the document library.
  - The lookup list will always have the same name.
  - The lookup list has a space in the name.</p>
  
  <p>This is what I've added to the xml:</p>
  
  <pre><code>  &lt;Field ID="{GUID}"
           Type="Lookup"
           List="$Resources:core,lists_Folder;/List%20Name"
           ShowField="Title"
           Name="MyLookupFieldName"
           DisplayName="MyLookupFieldName"
           StaticName="MyLookupFieldName"
           Hidden="FALSE"
           Required="FALSE"
           Sealed="TRUE"
           &gt;
  </code></pre>
  
  <p>When I then programatically add the content type to a document library I get an exception (with no useful information), and the following is logged to the sharepoint log:</p>
  
  <p>08/18/2009 17:13:39.50  w3wp.exe (0x08B8)                           0x11B0  Windows SharePoint Services     Database                        6f8g    Unexpected  Unexpected query execution failure, error code 8114. Additional error information from SQL Server is included below. "Error converting data type nvarchar to uniqueidentifier." Query text (if available): "{?=call proc_GetListMetaDataAndEventReceivers(?,?,?,?,?,?)}"</p>