Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

徵狀

假設您使用的是 Microsoft SQL Server 2014。 當您嘗試在本機編譯的儲存程式中使用datepart (weekday) 時,就會出現存取違規,且連線已結束。 此外,您會收到下列錯誤:

目前的命令發生嚴重錯誤。 結果(如果有的話)應該捨棄。

原因

發生這個問題的原因是 SQL Server 2014 中有一個缺陷。將 datepart 與 char 引數結合使用,就會將隱含轉換成 datetimeoffset。 原生儲存過程不支援 datetimeoffset。

每個新的 SQL Server 累計更新都包含所有的修正程式,以及前一個累積更新中所包含的所有安全性修正程式。 查看 SQL Server 的最新累計更新:

因應措施

若要解決此問題,請明確地轉換為支援的datetime 類型。

狀態

Microsoft 已確認本篇文章<適用於>一節所列之 Microsoft 產品確實有上述問題。

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×