我只想要一个SIMPLE sql server触发器(插入后)从插入的表中获取ID ...所以算法:
将新记录插入表格
触发器被称为
触发器从插入的记录中获取id并调用存储过程
我失败的尝试如下:
CREATE TRIGGER [dbo].[insertNewMarket]
ON [dbo].[markets]
AFTER insert
AS
BEGIN
declare @marketID int
SET NOCOUNT ON;
--SELECT ID from inserted
--set @marketID = Inserted.ID--get the inserted id and pass to stored proc
exec marketInsert @marketID
END
GO
答案 0 :(得分:3)
CREATE TRIGGER [dbo].[insertNewMarket]
ON [dbo].[markets]
AFTER insert
AS
BEGIN
declare @marketID int
SET NOCOUNT ON;
SELECT @marketID = ID from inserted
exec marketInsert @marketID
END
GO