用戶定義的表類型我創建了一個用戶derfined表類型如下問題,在存儲過程中
CREATE TYPE [emp_TT] AS TABLE
(
em_number char(12),
email varchar(50),
emergency_relation char(32),
option1 char(16),
)
GO
它得到的類型下,創建爲
,並試圖在使用它們我的存儲過程像
ALTER PROCEDURE [dbo].[uspInsertorUpdateArchibusINF]
@emp_TT AS emp_TT READONLY
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRANSACTION;
UPDATE e
SET e.email = t.email,
e.emergency_relation = t.emergency_relation,
e.option1 = t.option1,
FROM [afm].[em] e
INNER JOIN @emp_TT t ON e.em_id = t.em_id
INSERT INTO [afm].[em](email, emergency_relation, option1, em_id)
SELECT t.email
, t.emergency_relation,t.option1
, t.em_id
FROM @emp_TT t
WHERE NOT EXISTS (SELECT 1
FROM [afm].[em]
WHERE em_id = t.em_id)
COMMIT TRANSACTION;
END;
當我執行存儲過程重則引發錯誤像
Column, parameter, or variable #1: Cannot find data type emp_TT.
Parameter or variable '@emp_TT' has an invalid data type.
Must declare the table variable "@emp_TT".
Must declare the table variable "@emp_TT".
請讓我知道我在這裏失蹤
我不知道你會做什麼......只是先刪除它。從emp_TT AS emp_TT READONLY到emp_TT emp_TT READONLY在emp_TT變量處使用@ sign。 –