Create a connection to the server that can exist on the server after it is created and can be reused in different locations, similar to system functions
execsp_addlinkedserver'RemoteServer','','SQLOLEDB','192.168.3.225' execsp_addlinkedsrvlogin'RemoteServer','false',NULL,'SA',' [email protected]'
Delete Connection
exec ' RemoteServer ' ' droplogins '
How to use: (Connect. database. dbo. Table)
Select Top - * from RemoteServer.Suncome.dbo.AkEL
The following is called through a trigger
Create TriggerSyncbarcode onBarcodecompinfoafterUpdate,Insert asDeclare @Barcode nvarchar( -)Select @Barcode=Barcode frominsertedDeclare @num int--used to determine if the above number is present in the Bdvendor table to infer whether to add or modifySelect @num=COUNT(*) fromRemoteServer.Suncome.dbo.AkBarcodeCompInfowhereBarcode=@Barcodeif @num=0begin Insert intoRemoteServer.Suncome.dbo.AkBarcodeCompInfo (Barcode,ordernumber,printdate,linecode)Select [Barcode],[Workorderid],[PrintDate],[BC] frominsertedEnd
But there's no egg to use.
Right-click on "My Computer"--"manage"--"services and Applications"--"services"---start the "Distributed Transaction Coordinator" service, open the remote server and the local server 135 port after starting the distributed service. Because the remote distributed service requires this port to communicate.
1: Open "Control Panel"--"Administrative Tools"--"Component Services"
2: Right-click "My Computer" under "Computer"--"Properties"--select "MSDTC" tab
3: Click the "Security Configuration" button,
4: Network DTC Access is checked on, allow remote clients, allow remote administration, allow inbound,
Allow outbound, do not ask for authentication check on.
Note: The above steps require two servers to be configured.
SQL Server inserts data across databases