KB2938460 - FIX: An access violation occurs when you try to use datepart (weekday) in a natively compiled stored procedure in SQL Server 2014

Applies To
SQL Server 2014 Developer - duplicate (do not use) SQL Server 2014 Enterprise - duplicate (do not use) SQL Server 2014 Standard - duplicate (do not use)

Symptoms

Assume that you use Microsoft SQL Server 2014. When you try to use datepart (weekday) in a natively compiled stored procedure, there is an access violation and the connection is ended. Additionally, you receive the following error:

Note

A severe error occurred on the current command. The results, if any, should be discarded.

Cause

The issue occurs because a defect in SQL Server 2014.
Using datepart with a char argument introduces an implicit conversion to datetimeoffset. Native stored procedure does not support datetimeoffset.

Resolution

After the hotfix is applied, SQL Server will make a change to introduce new logic to convert the char argument to datetime2 for native stored procedure and datetimeoffset for regular stored procedure and constant folding.
The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 1 for SQL Server 2014 /en-us/help/2931693

About cumulative updates for SQL Server

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:

      

Workaround

To work around the issue, explicitly convert to a supported datetime type.

Status

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