I have two tables with data.
I want to compare first table of price column and second table of AVG(PRICE) column.
i.e price > AVG(PRICE).
And dispaly the alert message if the condition the true.
how to fid out if any one help this...
You cant do alert on the database side. Basically the database just hold your data. If you want to notify the data changes you can use either Trigger (only notified on the current scope ie, who inserted or updated). If you want to notify to multiple users independent of the scope use the Notification Service. Where you can send a email or message.
I am not sure about your purpose of this action?
HTH...
Joe
- Marked as answer by Ed Price - MSFTMicrosoft employee, Owner 8 hours 52 minutes ago
This data is real time data. I want to compare that data.
Can u please write a code.
I used trigger, Butits not working.
ALTER TRIGGER
averageTrigger ON dbo.averageofclose after insert asdeclare
@close moneydeclare
@avgclose moneyset
@close=(select close1 from inserted)set
@avgclose=(select AVERage from inserted)if
@close<@avgclosebegin
declare
@msg varchar(50)set
@msg='BUY'RAISERROR
(@msg,16,1);end
Help me this .....
Is this still an issue?
Thanks!
This trigger will work only for single record inserts.
if you want to make it work for set based inserts as well use
ALTER TRIGGER averageTrigger ON dbo.averageofclose after insert as if exists (select 1 from inserted where close1 < AVERage) begin declare @msg varchar(50) set @msg='BUY' RAISERROR(@msg,16,1); end