The two methods for cross-server SQL query are generally not available if the security settings are complete, but the internal network is still good.
The two methods for cross-server SQL query are generally not available if the security settings are complete, but the internal network is still good.
Select * from OPENDATASOURCE (
'Sqlodb ',
'Data Source = remote ip address; User ID = sa; Password = password'
). Database Name. dbo. Table Name
Insert local database name .. table name select * from OPENDATASOURCE (
'Sqlodb ',
'Data Source = remote ip address; User ID = sa; Password = password'
). Database Name. dbo. Table Name
Or use the connection Server:
-- Create linkServer
Exec sp_addrole server 'Alias ', '', 'sqloledb', '192. 168.2.5'
-- Log on to the linkServer
Exec sp_add1_srvlogin 'Alias ', 'false', null, 'sa', '123'
-- Query
Select * from alias. Database Name. dbo. Table Name
-- Delete the linked server when it is no longer in use
Exec sp_dropserver 'Alias ', 'droplogins'