Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help in Sending Mail

Author  Topic 

hirani_prashant
Yak Posting Veteran

93 Posts

Posted - 2008-07-14 : 08:38:41
Hello,

Table A Structure...
MktViewId UserId Alert_Me
11 200000 1

Table B Structure...
USERID Email_ID
200000 phirani@vcmpartners.com

Now i want to send mail to those users whose "Alert_Me" Value = 1.

Can any one help me out??

-- Regards
Prashant Hirani

svicky9
Posting Yak Master

232 Posts

Posted - 2008-07-14 : 12:12:13
are u talking about xp_sendmail in Sql server

Vic

http://vicdba.blogspot.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-14 : 13:15:42
Join them by user id and get the list of email id onto a temptable which has alert me as 1. Then use xp_sendmail to send mail to them.
Go to Top of Page

hirani_prashant
Yak Posting Veteran

93 Posts

Posted - 2008-07-15 : 08:13:17
Mine Below Query gives me output as a no of users's mail Id...

Query.....


Select DISTINCT UL.LOGIN_ID From
(
Select A.*, M.UserId FROM
(
Select Distinct MktViewID From MarketViewDef
Where PitID IN
( Select Distinct PitId From OrderTable O
Where
convert(datetime,convert(Nvarchar, CreateTime ,101)) = convert(datetime,convert(Nvarchar, GetDate() ,101)) AND
Version = (Select Max(Version) From OrderTable Where OrderId = O.OrderId) AND
Status <> 'D' )
) A
Inner Join MktView_Alert_Me M
ON
M.MktViewID = A.MktViewID AND
((M.Alert_Me_AnyTime= 1 Or M.Alert_Me = 1) Or
(M.Alert_Me_AnyTime= 1 AND M.Alert_Me = 1))
) B
Inner Join User_Login_Dtl UL
ON
B.UserId = UL.UserID

OutPut..

abc@vcmpartners.com
xyz.ab@vcmpartners.com

TO get no of users, i have to run above query at every updation done.

Can any one help me how can it possible by using trigger and 'sp_sendmail' store procedure...

Go to Top of Page
   

- Advertisement -