本文介绍了从触发器获取表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表:
CREATE TABLE 课程
(
lID nchar ( 4 ),
lName nvarchar ( 30 )
)
GO
CREATE TABLE SaveLog
(
tblname nvarchar ( 20 ),
objID nvarchar ( 20 ),
whatDO nvarchar ( 20 ),
sysUser nvarchar ( 20 ),
theDate datetime
)
GO
我有1个触发器:
CREATE TRIGGER InsertTrig
ON 课程
AFTER INSERT
AS BEGIN
INSERT INTO SaveLog(我应该怎么做)写在这里?请帮助我...)
END
我要找的结果是:
INSERT INTO 课程 VALUES (' NU01',' 数学')
SELECT * FROM SaveLog
课程NU01插入为2012.
解决方案
I have two table:
CREATE TABLE Lesson ( lID nchar(4), lName nvarchar(30) ) GO CREATE TABLE SaveLog ( tblname nvarchar(20), objID nvarchar(20), whatDO nvarchar(20), sysUser nvarchar(20), theDate datetime ) GO
I have 1 trigger:
CREATE TRIGGER InsertTrig ON Lesson AFTER INSERT AS BEGIN INSERT INTO SaveLog(what should i write here? pls, help me...) END
The result I am looking for is:
INSERT INTO Lesson VALUES('NU01', 'Math')
After
SELECT * FROM SaveLog
lesson NU01 Inserted as 2012.
解决方案
这篇关于从触发器获取表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!