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.
| Author |
Topic |
|
hirani_prashant
Yak Posting Veteran
93 Posts |
Posted - 2008-07-14 : 08:38:41
|
| Hello,Table A Structure...MktViewId UserId Alert_Me11 200000 1Table 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??-- RegardsPrashant Hirani |
|
|
svicky9
Posting Yak Master
232 Posts |
|
|
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. |
 |
|
|
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.comxyz.ab@vcmpartners.comTO 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... |
 |
|
|
|
|
|