sql server - using sp_send_dbmail with join -


i trying run following job on sql server agent , don't email.

i think there wrong way representing tables in inner join because if replace query simple query without joins, task works .

exec msdb.dbo.sp_send_dbmail     @profile_name = 'test_dev',     @recipients = 'xxx@gmail.com',     @query = ' select              percentage = convert(decimal(10,1),100 - (cast(count(distinct case when pd.exception  != ' ' pd.id  end) float)/cast(count(pd.id) float)*100))                           databasename.dbo.product p inner join databasename.dbo.logproduct pd                  on p.logid = pd.logid                                     responsetime < getdate() ,  requesttime > dateadd(minute, -150, getdate())                 ' ,     @subject = 'test',     @attach_query_result_as_file = 1 ; 

i use joins in @query parameter time without error. fact don't email sent typically indication query did not parse @ run time.

does query, joins, run in ssms directly? might consider creating variable @responsetime type??? , seting value of variable prior send_dbmail , passing value in replacing syntax @responsetime


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -