SQL 2000 确实有工作。
http://msdn.microsoft.com/en-us/library/aa215382(v=sql.80).aspx
如何创建作业 (Transact-SQL) 创建作业
1.执行 sp_add_job 创建作业。
2.执行 sp_add_jobstep 创建一个或多个作业步骤。
3. 执行 sp_add_jobschedule 创建作业计划。
SQL 2000 中的电子邮件可以通过 Outlook 完成,但这有点痛苦…… Blat 是免费的,不需要 Outlook 或 POP3。
为了避免附件并呈现漂亮的电子邮件,只需将行数据连接到 HTML 表中并将结果分配给正文。如果您需要超过 8000 个字符,则必须使用文本数据类型,但可能会有些困难
declare @result varchar(8000)
set @result = '<table>'
select @result = @result + '<tr><td>' + col1 + '</td><td>' + col2 + '</td></tr>'
from whereever
where something = something_else
order by 1
set @result = @result + '</table>'
http://www.blat.net/
示例代码: http: //www.devx.com/dbzone/Article/42178
Exec stp_BlatMail 'ServerName', 'fhtapia@gmail.com',
'System Maintenance: Low Memory', 'D:\Data\TempFiles\MemoryRpt.txt'
CREATE PROCEDURE stp_BlatMail (@FromName AS VARCHAR (1000), @To AS VARCHAR(1000),
@Subject AS VARCHAR(1000), @BODY AS VARCHAR(8000),
@ATTACHMENTS AS VARCHAR(1024) = NULL) AS
-- By: Francisco H Tapia <fhtapia@gmail.com>
-- Date: 8/19/2003
-- Purpose: Provide Outlook free SMTP Mailing
SET NOCOUNT ON
DECLARE @CMD as VARCHAR(8000), @result as INT
IF @TO = ''
BEGIN
SELECT 'ERROR: NO TO Name'
END
ELSE
BEGIN
SELECT @CMD = ' D:\Data\Common\blat.exe - -subject "'+ @Subject
+ '" -t "' + @To
+ '" -sender "SystemUID@Domain.com" -from "'
+ @FromName
+'" -f "SQLMail" -ReplyTo "SystemUID@Domain.com" -org "My Company Name" -x "X-INFO: " -noh
-noh2 -server "ExchangeServerName" -port 25 -u EmailUID -pw Password -body "'
+ LTRIM(RTRIM(@Body)) + '" '
+ ' -q '
If @ATTACHMENTS <> ''
BEGIN
SELECT @CMD = @CMD + ' -attach "' + @ATTACHMENTS + '" '
END
ELSE IF @Attachments IS NOT NULL
BEGIN
SELECT 'NO ATTACHMENT FOUND'
END
EXEC @result = master..xp_cmdShell @CMD, NO_OUTPUT
END
SET NOCOUNT OFF