title: Error converting data type varchar to datetime when running raw SQL but not when called by LINQ to SQL
body: <p>A client is getting an error when running my code.  They sent me the SQL from profilder.  </p>
  
  <p>When I paste it into SQL Server Management Studio it fails with: <strong>Error converting data type varchar to datetime</strong> </p>
  
  <p>However it doesn't fail when I run it on my local dev box or another clients production sever.</p>
  
  <p>To test I created a simple app with a L2S datacontext containing one entity that looks something like:</p>
  
  <pre><code>public class UserAccount 
  {
      public int Id { get; set; }
      public string Username { get; set; }
      public DateTime? LastActivity { get; set; }
  }
  </code></pre>
  
  <p>Insert a record and then update it:</p>
  
  <pre><code>var account = db.UserAccounts.Single(a =&gt; a.Username == "Mojo");
  account.LastActivity = DateTime.Now;
  db.SubmitChanges();
  </code></pre>
  
  <p>The records gets updated in the database.  But when I grab the T-SQL from Profiler:</p>
  
  <pre><code>exec sp_executesql N'UPDATE [UserAccount] SET [LastActivity] = @p2 WHERE ([Id] = @p0) AND ([Username] = @p1) AND ([LastActivity] IS NULL)',N'@p0 int,@p1 nvarchar(4),@p2 datetime',@p0=1,@p1=N'Mojo',@p2='2009-11-10 14:04:41.7470000' 
  </code></pre>
  
  <p>and execute it in SQL Server Management Studio I get: <strong>Error converting data type varchar to datetime</strong> </p>
  
  <p>What am I missing?</p>