SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Advice on getting an e-mail result sent every day
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jodders
Starting Member

United Kingdom
39 Posts

Posted - 02/24/2012 :  05:31:07  Show Profile  Reply with Quote
Hi there,

At the moment, I am experimenting how to use the sp_send_db_mail library and managed to get a very basic e-mail sent to me which means I am on the right track to get where I want to be. The trouble is I am having trouble entering in my select statement which I would like to add into the @Query part. The one below is a very basic example, but I think my syntax is wrong as that doesn't work either!

I have a select statement that I have prepared already, and was hoping to just copy and paste it in but I don't think it's that simple?

I have already set up a job under SQL Server Agent to run the below query, just need to figure how to insert my Select statement (which has a few joins! in to the @query part.


(*Update*) - i figured out why my simple query did not work, it's because I didn't specify the database I before the table name. School boy error.

What is the correct syntax if I have many joins and I am giving an individual table a name?

thanks








Any advice would be great :)



USE msdb

EXEC sp_send_dbmail @profile_name='SQL Administrator',

@recipients= 'anon@hotmail.com', 
@subject ='Hello World',
@body='How is it going',
--@query = 'select fruit from stall where fruit = apple;'


Edited by - jodders on 02/24/2012 06:06:26

jodders
Starting Member

United Kingdom
39 Posts

Posted - 02/24/2012 :  09:23:50  Show Profile  Reply with Quote
I have figured it all out, sorry for wasting people's time.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/24/2012 :  09:59:36  Show Profile  Reply with Quote
thats ok...
it would really be great if you can post the final query so that it will make sense for someone reading this thread at a later point.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000