select @mistakes=count(*) from lot_loc_mst where unit_cost >20 or unit_cost<=0 --料工费分开
IF (@mistakes>0)
BEGIN
SET @SQL='select * from item_mst'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'db_mail',
@execute_query_database='test',--数据库名
@recipients ='271289427@qq.com;',
@copy_recipients= '94397670@qq.com;33@qq.com;',
@subject=N'实际成本',
@query=@SQL,