Modify the trigger SQLServerJDBCDriver to monitor the modification of a table and then automatically modify the data of another table: cf_userinfo table structure: CREATETABLE [dbo]. [cf_userinfo] ([id] intNOTNULLIDENTITY (1,1), [uid] intNOTNULL, [name] varchar (50) COLLATEChinese_PRC_CI_ASNULL, CONSTRAINT
Modify the trigger SQLServer JDBC Driver to monitor the modification of a TABLE and then automatically modify the data of another TABLE: cf_userinfo TABLE structure: create table [dbo]. [cf_userinfo] ([id] int not null identity (1,1), [uid] int not null, [name] varchar (50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT
Modify the SQL Server JDBC Driver
After monitoring the modification of a TABLE, the data of another TABLE is automatically modified: cf_userinfo TABLE structure: create table [dbo]. [cf_userinfo] ([id] int not null identity (1,1), [uid] int not null, [name] varchar (50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK _ cf_userinfo _ 5535A963] primary key ([id]) ON [PRIMARY] GOuserinfo TABLE structure: create table [dbo]. [userinfo] ([id] int not null identity (1, 1), [name] varchar (50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK _ userinfo _ 5 34D60F1] primary key ([id]) ON [PRIMARY] GO create trigger for userinfo table create trigger userinfoupdateon userinfo for update -- monitor userinfo table modification asif update (name) -- if the name field is changed to begin print, the userinfo table modification event is triggered. Modify the cf_userinfo data ...... '; Declare @ id INT, @ newName varchar (50), @ uid int; -- select @ ID = id from deleted; if (exists (select * from cf_userinfo where uid = @ id) begin -- select @ newName = name from inserted; -- select @ UID = ID from deleted; update cf_userinfo set cf_userinfo.name = @ newName from userinfo where cf_userinfo.uid = @ UID end else print 'you do not need to modify the cf_userinfo table 'end