title: exec sp_executesql error 'Incorrect syntax near 1' when using datetime parameter
body: <p>I have a SSRSreport which sends the following text to the database :</p>
  
  <pre><code>EXEC ( 'DECLARE @TeamIds as TeamIdTableType ' + @Teams +
         ' EXEC rpt.DWTypeOfSicknessByCategoryReport @TeamIds , ' + 
         @DateFrom + ', ' + @DateTo + ', ' + @InputRankGroups + ', ' + 
         @SubCategories )
  </code></pre>
  
  <p>When I view this in profiler it interprets this as :</p>
  
  <pre><code>exec sp_executesql N'EXEC ( ''DECLARE @TeamIds as TeamIdTableType '' + @Teams +
   '' EXEC rpt.DWTypeOfSicknessByCategoryAndEmployeeDetailsReport @TeamIds, '' + 
  @DateFrom + '', '' + @DateTo + '', '' + @InputRankGroups + '', '' + 
  @SubCategories )',
  N'@Teams nvarchar(34),@DateFrom datetime,@DateTo datetime,
  @InputRankGroups varchar(1),@SubCategories bit',
  @Teams=N'INSERT INTO @TeamIds VALUES (5);',
  @DateFrom='2010-02-01 00:00:00',@DateTo='2010-04-30 00:00:00',
  @InputRankGroups=N'1',@SubCategories=1
  </code></pre>
  
  <p>When this sql runs it errors on the dates.</p>
  
  <p>I have tried changing the format of the date but it does not help. If I remove the dates it works fine.</p>