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:

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.

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.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Any additional feedback? (Optional)

Thank you for your feedback!

×