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.
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:
To work around the issue, explicitly convert to a supported datetime type.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.