Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implicit conversion from data type datetime to int is not allowed nested stored procedure

Why am I getting this error for a SP calling another SP. If I call the SP directory it works just fine.

Msg 257, Level 16, State 3, Procedure TEST1, Line 25
Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.

SP1 -> SP

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

BEGIN SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

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

SP

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], 

UPDATE

Line 25 is pointing to game.[Date] in the nested stored proc, but that is a datetime null type, and my temp table also has that, what gives?

like image 747
Mike Flynn Avatar asked Oct 12 '25 02:10

Mike Flynn


1 Answers

Found out why, it's because my parameter order on the inner SP select statement didnt match the temp table order.

like image 126
Mike Flynn Avatar answered Oct 14 '25 18:10

Mike Flynn