xp_sendmail使用表变量@query SQL Server 2000
我正在尝试使用xp_sendmail使用表变量@query SQL Server 2000,sql,email,sql-server-2000,Sql,Email,Sql Server 2000,我正在尝试使用xp\u sendmail通过电子邮件发送结果集。 当先前执行的查询有任何结果时,我需要发送电子邮件 将查询结果放入表变量/temp表中,然后 在xp_sendmail中,使用 Declare @table_var table(...) ..query execution.. EXEC master.dbo.xp_sendmail @recipients = 'xx@xx.com', @query = 'select * from @table_var' 这样说是错误的 @
xp\u sendmail
通过电子邮件发送结果集。
当先前执行的查询有任何结果时,我需要发送电子邮件
将查询结果放入表变量/temp表中,然后
在xp_sendmail中,使用
Declare @table_var table(...)
..query execution..
EXEC master.dbo.xp_sendmail @recipients = 'xx@xx.com',
@query = 'select * from @table_var'
这样说是错误的
@必须声明表_var
即使我使用临时表,我得到的信息是
无法引用tempdb数据库中的对象
有什么想法吗
提前感谢您需要使用一个真实的表格来完成此操作。试试
If exists (select * from sys.tables where name = 'mytable')
drop table mytable
Create Table mytable table(...)
..query execution..
EXEC master.dbo.xp_sendmail @recipients = 'xx@xx.com',
@query = 'select * from mydatabase.dbo.mytable'