MVC3中的MS SQL触发器 [英] MS SQL trigger in MVC3
问题描述
大家好,
我使用SQL触发器遇到一些问题.我有三个sql表,User,UserRole和
角色.
用户:UserID,UserName,Comment
UserRole:UserRoleID,UserID,RoleID
角色:RoleID,RoleName,Comment
当在用户表中插入行时,我具有UserID和RoleID.
如何创建触发器以自动保存在UserRole表中.
我完全是新手.顺便说一句,我正在使用Linq到SQL类
使用MVC3.
请帮帮我!
最佳Rgds,
df
Hi all,
i face some issue using SQL trigger. I have three sql tables, User, UserRole and
Role.
User : UserID,UserName,Comment
UserRole : UserRoleID,UserID,RoleID
Role : RoleID, RoleName, Comment
I had UserID and RoleID when row had been inserted in User table.
how do i create trigger to save automatically in UserRole table.
i am totally newbie in trigger. By the way, i am using Linq to SQL class
with MVC3.
Pls, help me !
Best Rgds,
df
推荐答案
嘿,
您应该在用户表中创建一个触发器.
Hey,
You should create a Trigger into the User table.
CREATE TRIGGER tr_InsertRole
ON [User]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
--WRITE SQL statement to insert Role into User Role Table
END
GO
这篇关于MVC3中的MS SQL触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!