下面是我到目前为止存储的proc我执行时一直收到此错误: 消息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
答案 0 :(得分: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