title: Why do I get an error using CONVERT on one of the arguments of a stored proc call?
body: <p>For some reason, the following gives me an error:</p>
  
  <pre><code>DECLARE @Param1 DATETIME2(3)=...; -- Assign some date/time
  DECLARE @Param2 DATETIME;
  DECLARE @Param3 DATETIME;
  
  EXEC dbo.SomeStoredProc CONVERT(DATE, @Param1), @Param2 output, @Param3 output;
  </code></pre>
  
  <p>The output is a compilation failure:</p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword
    'CONVERT'.</p>
  </blockquote>
  
  <p>Changing it to the following fixes the problem:</p>
  
  <pre><code>DECLARE @Param1 DATETIME2(3)=...; -- Assign some date/time
  DECLARE @Param2 DATETIME;
  DECLARE @Param3 DATETIME;
  DECLARE @TempDate DATE=CONVERT(DATE,@Param1);
  
  EXEC dbo.SomeStoredProc @TempDate, @Param2 output, @Param3 output;
  </code></pre>