1

以下是我到目前为止的存储过程,执行时我不断收到此错误:消息 137,级别 16,状态 1,过程 db_recession_band_dates_save,第 18 行必须声明标量变量“@dates”。

ALTER PROCEDURE [dbo].[Dates_Save]
@Loc VARCHAR(75),
@dates StartEndDateType READONLY  
AS
BEGIN
DECLARE @id int
SELECT @id = MYINTFIELD FROM date_locations
IF @id IS NULL
BEGIN
    INSERT INTO db_recession_bands VALUES (@loc)
    SET @id = @@IDENTITY
END
INSERT INTO db_recession_band_dates VALUES (@id,@dates)      
END
4

1 回答 1

1

如果 StartEndDateType 是用户定义的表类型,那么您将其视为表。

改变这个:

INSERT INTO db_recession_band_dates VALUES (@id,@dates)

进入类似的东西

INSERT INTO db_recession_band_dates (<COLUMN LIST>) -- don't do blind inserts it will hurt you at some point in the future
SELECT @id, <COLUMN LIST>
FROM @dates
于 2013-06-13T20:31:54.837 回答