gpt4 book ai didi

sql - 不允许从数据类型 datetime 到 int 的隐式转换嵌套存储过程

转载 作者:行者123 更新时间:2023-12-04 02:07:25 24 4
gpt4 key购买 nike

为什么 SP 调用另一个 SP 时会出现此错误。如果我调用 SP 目录,它工作得很好。

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

开始 设置无计数; 设置事务隔离级别读取未提交;

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

更新

第 25 行指向嵌套存储过程中的 game.[Date],但这是一个 datetime null 类型,我的临时表也有它,这是怎么回事?

最佳答案

找到原因了,是因为我在内部SP select语句中的参数顺序与临时表顺序不匹配。

关于sql - 不允许从数据类型 datetime 到 int 的隐式转换嵌套存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23403007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com