Ways to access another database server table through SQL Server view

Source: Internet
Author: User

Today the project manager came running to yell at me and say what I did before I made a lot of interfaces why didn't do it, I directly fire, before obviously not this thing ...

But things still have to be solved, but fortunately, two projects are all used SQL Server, you can quickly solve the problem by cross-database view, save a lot of work. How to do it? Let's see below.

text :

Sometimes we have access to other SQL Server databases, which we can do with a view using OpenDataSource (supported by SQL Server 2000 or later). For example:

Create VIEW [dbo]. [Vtablename]

Asselect * from opendatasource ( ' SQLOLEDB ', ' Pwd=loginpassword; Uid=otherserveruserid;initial Catalog=databasename; Server=dataserver '). Databasename.dbo. [TableName] Go accesses another database server in the identity of the UID and PWD. where : PWD : Refers to another database server login password UID : Refers to another database server login ID (user name) Initial Catalog : Indicates the database Server: Indicates that we can read the data in the following ways: Select * from [dbo]. [Vtablename]

Ways to access another database server table through SQL Server view

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.