An application cannot connect to a contained database when connection pooling is enabled in SQL Server 2012 or SQL Server 2014

Symptoms

Consider the following scenario:
  • You have a contained database in Microsoft SQL Server 2012 or SQL Server 2014.
  • An application tries to connect to the contained database by enabling connection pooling.
  • The application uses SQL Server authentication.

In this scenario, the application may be unable to connect to the database. Additionally, you find errors that resemble the following in the SQL Server error log:

datetime Logon Error: 18456, Severity: 14, State: 5.
datetime Logon Login failed for user 'SID'. Reason: Could not find a login matching the name provided [Client:]
datetime spid# Error: 18056, Severity: 20, State: 5.
datetime spid# The client was unable to reuse a session with SPID #, which had been reset for connection pooling. The failure ID is #. This error may have been caused by an earlier operation failing. Check the error logs for failed operations immediately before this error message.
Note This problem does not occur the first time that a connection to a contained database occurs. However, the problem does occur on all successive attempts.

Resolution

The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 1 for SQL Server 2014

Cumulative Update 7 for SQL Server 2012 SP1

About cumulative updates for SQL Server

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

More Information

This update also fixes another problem in which the following built-in functions return the user SID instead of the user name:
  • SUSER_SNAME
  • SUSER_NAME
  • SYSTEM_USER

Note This update makes sure that the user name is always returned by these functions, whether or not a contained database is used.

References

See the terminology Microsoft uses to describe software updates.
Properties

Article ID: 2894326 - Last Review: Apr 22, 2014 - Revision: 1

Microsoft SQL Server 2012 Developer, Microsoft SQL Server 2012 Enterprise, Microsoft SQL Server 2012 Express, Microsoft SQL Server 2012 Parallel Data Warehouse, Microsoft SQL Server 2012 Standard, Microsoft SQL Server 2014 Developer, Microsoft SQL Server 2014 Developer, Microsoft SQL Server 2014 Developer, Microsoft SQL Server 2014 Developer, Microsoft SQL Server 2014 Enterprise, Microsoft SQL Server 2014 Enterprise, Microsoft SQL Server 2014 Enterprise, Microsoft SQL Server 2014 Enterprise, Microsoft SQL Server 2014 Standard, Microsoft SQL Server 2014 Standard, Microsoft SQL Server 2014 Standard, Microsoft SQL Server 2014 Standard

Feedback