Home > database >  In SQL update the data in a database table, link to the server at the same time a table in a databas
In SQL update the data in a database table, link to the server at the same time a table in a databas

Time:05-01

Demand is: SQL update a data in a database table, at the same time, according to the data, which is a database to update the link server a table in a field value
Try to write a trigger, but if you want to update the links in the server database table, need to use a distributed transaction, need to open port 135, but open port 135 unsafe, general server is disabled, is there anything else to write?

Can then trigger call a stored procedure?

The test data are as follows:

The first database:
The create table A
(
Id int,
The name varchar (500),
Remark varchar (500)
)

Insert into A values
(1, 'zhangsan', 'mathematics'),
(2, 'lisi', 'English'),
(3, 'wangwu', 'Chinese')

Link to the server database:
The create table B
(
Id int,
The name varchar (500),
Remark varchar (500)
)

Insert into B values
(1, 'zhangsan', 'English'),
(3, 'wangwu', 'sports')


Modify A remark in the field, according to Anderson, d=[LINK2.25] test. The dbo. B.i d modified B remark fields, change to be the same as A

Consult everybody a great god, and how to write

CodePudding user response:

Trigger, the trigger in the associated updates.
As for safety, you can set the server side Windows firewall rules: access port 135 allow remote machines to be each other's IP.

CodePudding user response:

Have links to the address of the server, direct implementation Update_Trigger can, do not need to open a launch business,

CodePudding user response:

Trigger updates the remote table, the risk is bigger, is not recommended,
The best program to complete,

  • Related