はこれを試してみてくださいません:
IF OBJECT_ID('[dbo].[Demo]') IS NOT NULL
BEGIN
DROP TABLE [dbo].[Demo];
END;
CREATE TABLE [dbo].[Demo]
(
[test1] INT NOT NULL
,[test2] INT
,[test3] INT
);
GO
/*
Msg 515, Level 16, State 2, Line 15
Cannot insert the value NULL into column 'test1', table 'TEST.dbo.Demo'; column does not allow nulls. INSERT fails.
*/
INSERT INTO [dbo].[Demo] ([test2], [test3])
VALUES (1, 1);
GO
CREATE TRIGGER TRG_DEMO_I_I ON [dbo].[Demo] INSTEAD OF INSERT AS
BEGIN
INSERT INTO [dbo].[Demo] ([test1], [test2], [test3])
SELECT [test2] + [test3], [test2], [test3]
FROM inserted;
END;
GO
-- this is OK
INSERT INTO [dbo].[Demo] ([test2], [test3])
VALUES (1, 1);
SELECT *
FROM [dbo].[Demo];
GO
INSERT'がトリガーする前に、SQL Serverは '持っていません - 唯一のオプション(場合をあなたは本当にトリガーを使用しなければなりません)は、INSERTの代わりにトリガー –