Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query tables on different database servers with multiple tables by sqlserver

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to query tables on different database servers by sqlserver". In daily operation, I believe many people have doubts about how to query tables on different database servers by sqlserver. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to query tables on different database servers by sqlserver". Next, please follow the editor to study!

The first method: copy the code as follows: / * create a linked server * / exec sp_addlinkedserver 'srv_lnk','','sqloledb',' barcode database IP address' exec sp_addlinkedsrvlogin 'srv_lnk','false',null,' username,' password'go / * query example * / SELECT A.ListCode FROM srv_lnk. Barcode database name. Dbo.ME_ListCode A, IM_BarLend B WHERE A.ListCode=B.ListCode go / * Delete linked server * / exec sp_dropserver 'srv_lnk','droplogins'

The second method: copy the code as follows: exec sp_configure 'show advanced options',1 reconfigure exec sp_configure' Ad Hoc Distributed Queries',1 reconfigure go select * from Product p inner join opendatasource ('SQLOLEDB','Data Source=Macaco-Online;user ID=sa;password=sa password;'). Company.dbo.Product p2 on P.PID=p2.PID go exec sp_configure'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure go

At this point, the study on "how to query tables on different database servers with multiple tables by sqlserver" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report