SQL SERVER 通過作業來郵件發送SQL結果報錯。 (錯誤 22050)

來源:互聯網
上載者:User

標籤:郵件伺服器   win   nts   state   執行   sel   file   send   from   

環境:SQL SERVER2008R2

癥狀描述:

作業中執行如下指令碼報錯:已以使用者 NT AUTHORITY\NETWORK SERVICE 的身份執行。 Error formatting query, probably invalid parameters [SQLSTATE 42000] (錯誤 22050).  該步驟失敗。

但在ssms用戶端中直接執行是可以正常發送。。。

Exec
dbo.sp_send_dbmail
@profile_name=‘郵件伺服器‘,
@recipients=‘收件者‘,
@subject=‘郵件標題‘,
@body=‘本文‘,
@query =‘select * from table‘

 

很奇怪,做了很多測驗想找出哪個環節的問題,過程不多贅述,直接說我的解決方案。

最後懷疑資料庫版本的問題。現有版本是:

Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)
Apr 2 2010 15:48:46
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

 

找了台測試機打上SP1補丁做測試:

Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)
Jun 17 2011 00:54:03
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

 

在作業中終於可以正常發送郵件。

當然可能會有更好的解決辦法,不需要打補丁。知道的請不吝賜教。

 

SQL SERVER 通過作業來郵件發送SQL結果報錯。 (錯誤 22050)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.