A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/sql/docs/sqlserver/manage-linked-servers below:

Manage linked servers | Cloud SQL for SQL Server

Manage linked servers

Stay organized with collections Save and categorize content based on your preferences.

MySQL   |  PostgreSQL   |  SQL Server

This page provides information about how to manage linked servers on your Cloud SQL instance, including enrolling an instance, adding a linked server, and querying a linked server.

Enroll your instance to allow linked servers

To add the cloudsql enable linked servers flag to your instance, use the following command:

gcloud sql instances patch INSTANCE_NAME --database-flags="cloudsql enable linked servers"=on

Replace INSTANCE_NAME with the name of the instance that you want to use for linking servers.

For more information, see configure database flags.

Add a linked server

To add a linked server, run the Transact-SQL sp_addlinkedserver command:

EXEC master.dbo.sp_addlinkedserver
    @server = N'LINKED_SERVER_NAME',
    @srvproduct=N'',
    @provider=N'SQLNCLI',
    @datasrc=N'TARGET_SERVER_ID'

Replace the following:

To add user mapping for a user who is currently logged in, run the following command:

EXEC master.dbo.sp_addlinkedsrvlogin
    @rmtsrvname=N'LINKED_SERVER_NAME',
    @useself=N'True'

Replace LINKED_SERVER_NAME with the name of the linked server.

To create or update the default remote login and password, and apply it to all local logins, run the following command:

EXEC master.dbo.sp_addlinkedsrvlogin
    @rmtsrvname=N'LINKED_SERVER_NAME',
    @useself=N'False',
    @locallogin=N'LOGIN',
    @rmtuser=N'USER_ID',
    @rmtpassword='PASSWORD';

Replace the following:

Add a linked server with an encrypted connection

To add a linked server using an encrypted connection, run the Transact-SQL sp_addlinkedserver command:

EXEC master.dbo.sp_addlinkedserver
    @server = N'LINKED_SERVER_NAME',
    @srvproduct=N'',
    @provider=N'SQLNCLI',
    @datasrc=N'TARGET_SERVER_ID,
    @provstr=N'Encrypt=yes;'

Replace the following:

If the name of the server is different from the name in the certificate, you need to indicate that the SQL Server can trust the server certificate. To update the provider string, run the following command:

EXEC master.dbo.sp_addlinkedserver
    @server = N'LINKED_SERVER_NAME',
    @srvproduct=N'',
    @provider=N'SQLNCLI',
    @datasrc=N'TARGET_SERVER_ID,
    @provstr=N'Encrypt=yes;TrustServerCertificate=yes;'

Replace the following:

Linked server queries

Cloud SQL supports the use of four-part names to query linked servers (server name, database name, schema name, and object name), in addition to the following commands:

Note: Cloud SQL doesn't support OPENROWSET as a way to query a linked server.

For more information, see Compare query remote execution options.

Enable remote procedure calls on a linked server

Remote procedure calls (RPC) let you run stored procedures on linked servers. To add RPC, you run the Transact-SQL sp_serveroption command with an RPC argument. There are two RPC arguments:

Use the following sp_serveroption command with the rpc argument to enable RPC from LINKED_SERVER_NAME:

EXEC sp_serveroption
    @server='LINKED_SERVER_NAME',
    @optname='rpc',
    @optvalue='TRUE'

Replace LINKED_SERVER_NAME with the name of the linked server.

Use the following sp_serveroption command with the rpc out argument to enable RPC:

EXEC sp_serveroption
    @server='LINKED_SERVER_NAME',
    @optname='rpc out',
    @optvalue='TRUE'

Replace LINKED_SERVER_NAME with the name of the linked server.

Remove the user mapping for a linked server

To remove a user mapping that you previously added, run the following command:

EXEC master.dbo.sp_droplinkedsrvlogin
    @rmtsrvname=N'LINKED_SERVER_NAME',
    @locallogin=N'LOGIN';

Replace the following:

Remove an enrolled instance from allowing linked servers

To remove linked servers, do the following:

Troubleshoot Error message Troubleshooting Msg 7411, Level 16, State 1, Line 25

Server 'LINKED_SERVER_NAME' is not configured for DATA ACCESS.

The DataAccess option is disabled. Run the following command to enable data access:
EXEC sp_serveroption
    @server='LINKED_SERVER_NAME',
    @optname='data access',
    @optvalue='TRUE'

Replace LINKED_SERVER_NAME with the name of the linked server.

Access to the remote server is denied because no login-mapping exists. (Microsoft SQL Server, Error: 7416) If you have this issue while establishing an encrypted connection, you need to try another way to provide the user ID when you access the linked server. To do this, run the following command:
EXEC master.dbo.sp_addlinkedserver
   @server = N'LINKED_SERVER_NAME',
   @srvproduct= N'',
   @provider= N'SQLNCLI',
   @datasrc= N'TARGET_SERVER_ID',
   @provstr= N'Encrypt=yes;TrustServerCertificate=yes;User ID=USER_ID'

Replace the following:

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4