一.將表數(shù)據(jù) 導(dǎo)出 到EXCEL。 二.配置SQL SERVER2008 的Database Mail。 三.執(zhí)行 郵件 發(fā)送 腳本 。 一.將表數(shù)據(jù) 導(dǎo)出 到EXCEL。 1,如果xp_cmdshell沒有開啟,開啟xp_cmdshell的方法 -- To allow advanced options to be changed. EXEC sp_configure 'show a
一.將表數(shù)據(jù)導(dǎo)出到EXCEL。
二.配置SQL SERVER2008 的>Database Mail。
三.執(zhí)行郵件發(fā)送腳本。
一.將表數(shù)據(jù)導(dǎo)出到EXCEL。
1,如果xp_cmdshell沒有開啟,開啟xp_cmdshell的方法
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
2,執(zhí)行導(dǎo)出腳本
EXEC master..xp_cmdshell 'bcp "SELECT * FROM testDB.dbo.Table_1 " queryout C:/TEMP/test.xls -c -Utest -P123' --Sservername
二.配置SQL SERVER2008 的>Database Mail。
1.Management-->Database Mail(Right Click)-->Configure Database Mail(這里需要使用默認(rèn)的SMTP服務(wù)器)
2.After send test mail success.
幫助可參考:ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/3bdb0e6d-9d09-465e-9a3f-7a8ccd53aca8.htm
三.執(zhí)行郵件發(fā)送腳本。
USE msdb
GO
EXEC sp_send_dbmail @profile_name='SQLMailProfileName',
@recipients='wqiu@test.com', @subject='Test message',
@body='This is the body of the test message. _
Congrats Database Mail Received By you Successfully.'
,@file_attachments = 'C:/TEMP/test.xls'
幫助可參考:ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/f1d7a795-a3fd-4043-ac4b-c781e76dab47.htm
對數(shù)據(jù)庫郵件進(jìn)行故障排除:
http://msdn.microsoft.com/zh-cn/library/ms188663.aspx
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com