我正在为@StartFixtureDay检索必须声明的标量变量错误,但不确定我需要做什么或看到我的代码出现问题:
CREATE PROCEDURE [dbo].[Date_Insert]
AS
SET NOCOUNT ON
BEGIN
DECLARE @StartFixtureDay DATE
SET @StartFixtureDay = CAST(GETDATE() AS DATE)
;WITH League_Dates AS (
...
SELECT rn,
week_number,
DATEADD(day, week_number - 1, @StartFixtureDay) AS WeekNumber,
...
...下面的执行官是在一个单独的页面上
EXEC [dbo].[Date_Insert] @StartFixtureDay
答案 0 :(得分:0)
您必须将@StartFixtureDay声明为存储过程
的参数CREATE PROCEDURE [dbo].[Date_Insert] (@StartFixtureDay date)
AS
...
答案 1 :(得分:0)
该过程未被定义为具有参数但您正在传递过程。
您需要先将参数放入过程定义中,然后才能传递它
答案 2 :(得分:0)
您已在存储过程中声明@StartFixtureDay
。
当您致电EXEC
时,您的手术超出了您的范围。
而这个OUTside代码确实不知道INside变量。
在EXEC
之前声明您的变量并在您的过程中声明参数
CREATE PROCEDURE [dbo].[Date_Insert] (@ParamName DATE)
AS
DECLARE @StartFixtureDay DATE
SET @StartFixtureDay = @ParamName
...
...
DECLARE @OutsideVriable DATE
SET @OutsideVriable = CAST(GETDATE() AS DATE)
EXEC [dbo].[Date_Insert] @OutsideVariable
答案 3 :(得分:0)
如上所述,根据您的执行程序提出建议,您的datatime参数需要定义。
你也写错了,请更正
CREATE PROCEDURE [dbo].[Date_Insert]
AS
SET NOCOUNT ON
BEGIN
DECLARE @StartFixtureDay DATE
SET @StartFixtureDay = ( Select CAST(GETDATE() AS DATE)) --direct cast not work, need to select keyword