不知道怎么去获取新增加信息的事件:
瞎写一通!还望大虾帮忙!
CREATE TRIGGER Trigger_InsertInfo ON Users FOR UPDATE AS
BEGIN
declare @user_id char(20),@Password char(20),@RealName char(20),@sex int,@tel char(20),@email char(40),@submit_date Datetime
DECLARE Word_cursor CURSOR FOR
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from users
OPEN Word_cursor
FETCH NEXT FROM Word_cursor into @user_id,@Password,@RealName,@sex,@tel,@email,@submit_date
WHILE (@@FETCH_STATUS =0)
BEGIN
insert into users_Back(user_id,Password,RealName,sex,tel,email,submit_date) values(@user_id,@Password,@RealName,@sex,@tel,@email,@submit_date)
FETCH NEXT FROM Word_cursor into @user_id,@Password,@RealName,@sex,@tel,@email,@submit_date
END
close Word_cursor
deallocate Word_cursor
END
5 个解决方案
#1
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
insert users_Back(user_id,Password,RealName,sex,tel,email,submit_date)
select user_id,Password,RealName,sex,tel,email,submit_date from inserted
END
ON Users FOR INSERT AS
BEGIN
insert users_Back(user_id,Password,RealName,sex,tel,email,submit_date)
select user_id,Password,RealName,sex,tel,email,submit_date from inserted
END
#2
表新增记录的时候,会存到inserted表中,只需从inserted中检索相当的记录,插到另外的表中即可
#3
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
ON Users FOR INSERT AS
BEGIN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
#4
同意楼上
#5
将楼上的楼上加一句:
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
IF @@rowcount=0
RETURN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
IF @@rowcount=0
RETURN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
#1
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
insert users_Back(user_id,Password,RealName,sex,tel,email,submit_date)
select user_id,Password,RealName,sex,tel,email,submit_date from inserted
END
ON Users FOR INSERT AS
BEGIN
insert users_Back(user_id,Password,RealName,sex,tel,email,submit_date)
select user_id,Password,RealName,sex,tel,email,submit_date from inserted
END
#2
表新增记录的时候,会存到inserted表中,只需从inserted中检索相当的记录,插到另外的表中即可
#3
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
ON Users FOR INSERT AS
BEGIN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
#4
同意楼上
#5
将楼上的楼上加一句:
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
IF @@rowcount=0
RETURN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END
CREATE TRIGGER Trigger_InsertInfo
ON Users FOR INSERT AS
BEGIN
IF @@rowcount=0
RETURN
insert wordbook_bbs_users(user_id,Password,RealName,sex,tel,email,submit_date)
select UserId,PassWOrd,UserName,Sex,PhoneNumber,Email,PurchaseDate from inserted
END