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 2012 Forums
 SQL Server Administration (2012)
 Query Recordcount

Author  Topic 

egemen_ates
Yak Posting Veteran

76 Posts

Posted - 2014-04-24 : 11:13:46
Hello myfriends,
I want to create alert for query recordcount,
I will explain with example

One user execute query,query return 2000 000 rows ,I want to send mail

for query recordcount greater than 1000 000

how can i do its possible
thank you,

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-04-24 : 17:09:09
If your users are selecting directly against a table, I know of no way to generate such a message.

If they are accessing the data through a stored procedure, after the select statement, examine the @@rowcount variable, and if that is more than your specified count, use sp_send_dbmail to send the e-mail.
http://technet.microsoft.com/en-us/library/ms190307.aspx
....
YourSelectStatement inthe stored proc here
if (@@rowcount > 1000000)
begin
exec sp_send_dbmail ....
end

Go to Top of Page

egemen_ates
Yak Posting Veteran

76 Posts

Posted - 2014-04-25 : 07:42:38
Thank You James,But I dont this because my system has alot of query,This way very hard for me ,
How can i do another way ?
quote:
Originally posted by James K

If your users are selecting directly against a table, I know of no way to generate such a message.

If they are accessing the data through a stored procedure, after the select statement, examine the @@rowcount variable, and if that is more than your specified count, use sp_send_dbmail to send the e-mail.
http://technet.microsoft.com/en-us/library/ms190307.aspx
....
YourSelectStatement inthe stored proc here
if (@@rowcount > 1000000)
begin
exec sp_send_dbmail ....
end



Go to Top of Page

egemen_ates
Yak Posting Veteran

76 Posts

Posted - 2014-04-25 : 08:23:33
I found this article
http://beyondrelational.com/modules/2/blogs/60/posts/12060/get-row-count-using-sql-profiler.aspx

This is ok for me.
Thank you.
Go to Top of Page
   

- Advertisement -