SQL 跨服务器数据库增、删、改、查(二)

时间:2022-01-06 21:56:57
--创建链接服务器
exec sp_addlinkedserver 'jx3xxiednr3ucidf', ' ', 'SQLOLEDB', 'jx3xxiednr3ucidf'
exec sp_addlinkedsrvlogin 'jx3xxiednr3ucidf', 'false',null, 'sa', 'Aa12345' --增
INSERT INTO jx3xxiednr3ucid.yyg.dbo.T_Tabel_a ([Name])VALUES('张慧')
--删
DELETE jx3xxiednr3ucid.yyg.dbo.T_Tabel_a WHERE [Name] = '张慧'
--改
UPDATE jx3xxiednr3ucid.yyg.dbo.T_Tabel_a SET [Name] = '陈秋水' WHERE Id = 4
--查
SELECT * FROM jx3xxiednr3ucid.yyg.dbo.T_Tabel_a --删除链接服务器
exec sp_dropserver 'jx3xxiednr3ucidf', 'droplogins'