Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 3.21 KB

File metadata and controls

58 lines (43 loc) · 3.21 KB
title Creating a Valid Connection String Using Shared Memory Protocol
ms.custom seo-lt-2019
ms.date 03/14/2017
ms.prod sql
ms.prod_service sql-tools
ms.reviewer
ms.technology configuration
ms.topic conceptual
helpviewer_keywords
connection strings [Database Engine], shared memory
aliases [SQL Server], shared memory
ms.assetid 5fff42e8-377f-4b40-b0c8-b02393f8a1af
author markingmyname
ms.author maghan
monikerRange >=sql-server-2016||=sqlallproducts-allversions

Creating a Valid Connection String Using Shared Memory Protocol

[!INCLUDEappliesto-ss-xxxx-xxxx-xxx-md-winonly] Connections to [!INCLUDEmsCoName] [!INCLUDEssNoVersion] from a client running on the same computer use the shared memory protocol. Shared memory has no configurable properties. Shared memory is always tried first, and cannot be moved from the top position of the Enabled Protocols list in the Client Protocols Properties list. The Shared Memory protocol can be disabled, which is useful when troubleshooting one of the other protocols.

You cannot create an alias using the shared memory protocol, but if shared memory is enabled, then connecting to the [!INCLUDEssDE] by name, creates a shared memory connection. A shared memory connection string uses the format lpc:<servername>[\instancename].

Connecting to the Local Server

When connecting to [!INCLUDEssNoVersion] running on the same computer as the client, you can use (local) as the server name. This is not encouraged as it leads to ambiguity, however it can be useful when the client is known to be running on the intended computer. For instance, when creating an application for mobile disconnected users, such as a sales force, where [!INCLUDEssNoVersion] will run on laptop computers and store project data, a client connecting to (local) would always connect to the [!INCLUDEssNoVersion] running on the laptop. The word localhost or a period (.) can be used in place of (local).

Verifying your Connection Protocol

The following query will return the protocol used for the current connection.

SELECT net_transport   
FROM sys.dm_exec_connections   
WHERE session_id = @@SPID;  
  

Examples:

The following names will connect to the local computer with the shared memory protocol if it is enabled:

<servername>

<servername>\<instancename>

(local)

localhost

You cannot create an alias for a shared memory connection.

Note

Specifying an IP Address in the Server box will result in a TCP/IP connection.

See Also

Creating a Valid Connection String Using TCP IP
Creating a Valid Connection String Using Named Pipes
Choosing a Network Protocol