title: Implicit conversion from data type datetime to int is not allowed nested stored procedure
body: <p>Why am I getting this error for a SP calling another SP.  If I call the SP directory it works just fine. </p>
  
  <blockquote>
    <p>Msg 257, Level 16, State 3, Procedure TEST1, Line 25<br>
    Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.</p>
  </blockquote>
  
  <p><strong>SP1 -> SP</strong></p>
  
  <pre><code>ALTER PROCEDURE [TEST].[TEST1]
      @EventId INT = NULL,
      @MemberId INT = NULL,
      @Type INT = NULL,
      @Scheduled BIT = 0,
      @DivisionId INT = NULL,
      @DivisionTeamId INT = NULL,
      @Date DATETIME = NULL,
      @GymCourtId INT = NULL
  AS
  </code></pre>
  
  <p>BEGIN
      SET NOCOUNT ON;
      SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;</p>
  
  <pre><code>CREATE TABLE #GridGames (
      [Id] [int] NOT NULL,
      [Number] [int] NULL,
      [Round] [int] NULL,
      [GameType] [int] NULL,
  .
  .
  .
  .
  INSERT INTO #GridGames 
  EXEC [TEST].[TEST] @EventId, @MemberId, @Type, @Scheduled, @DivisionId, @DivisionTeamId, @Date, @GymCourtId
  </code></pre>
  
  <p><strong>SP</strong></p>
  
  <pre><code>ALTER PROCEDURE [TEST].[TEST]
      @EventId INT = NULL,
      @MemberId INT = NULL,
      @Type INT = NULL,
      @Scheduled BIT = 0,
      @DivisionId INT = NULL,
      @DivisionTeamId INT = NULL,
      @Date DATETIME = NULL,
      @GymCourtId INT = NULL
  AS
  BEGIN
      DECLARE @DayAhead DATETIME;
  
      IF(@Date IS NOT NULL)
      BEGIN
          SET @DayAhead = DATEADD (DAY , 1 , @Date);
      END
  
  SELECT
          game.Id,
          game.[Type] AS GameType,
          game.[Date], 
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Line 25 is pointing to <code>game.[Date]</code> in the nested stored proc, but that is a datetime null type, and my temp table also has that, what gives?</p>