SQLserver cross-database connection

Source: Internet
Author: User
Welcome to the Windows community forum and interact with 3 million technical staff. 1. Connect to OPENDATASOURCE (SQLOLEDB, Server10.252.35.194GZ, 1435; U) across databases ). Mrmsv3_backup_im. [dbo]. [s2] t. The variables include IP address, account, password, database name, account name, and table.

Welcome to the Windows community forum and interact with 3 million technical staff> enter 1. -- connect to OPENDATASOURCE directly across databases ('sqlodb', 'server = 10.252.35.194 \ GZ, 1435; Uid = mrms2; pwd = mrms1234 '). Mrmsv3_backup_im. [dbo]. [s2] t. The variables include IP address, account, password, database name, account name, and table.

Welcome to the Windows community forum and interact with 3 million technicians>

1. -- direct cross-database connection

OPENDATASOURCE ('sqlodb', 'server = 10.252.35.194 \ GZ, 1435; Uid = mrms2; pwd = mrms1234 '). Mrmsv3_backup_im. [dbo]. [s2] t

The variables include IP address, account, password, database name, account name, and table name.

2. -- establish a Remote Access Connection

For example, if I am on the local machine, I want to easily access 10.244.8.193 (sa, 1), where sa/1 is the account password.

You need to execute the following commands on the local machine:

Exec sp_addrole server 'bowinserver', '', 'sqloledb', '10. 244.8.193'

Exec sp_add1_srvlogin 'winserver', 'false', null, 'sa ', '1'

The variables include user-defined names, IP addresses, accounts, and passwords.

In the command, the bowinserver is the custom name. Next I want to access the cf_user TABLE OF THE mrmsv3_cf_dev database in 10.244.8.193 (sa, 1:

SELECT * FROM bowinserver. mrmsv3_cf_dev.dbo.cf_user

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.