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
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 Query Recordcount
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

egemen_ates
Yak Posting Veteran

Turkey
76 Posts

Posted - 04/24/2014 :  11:13:46  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3565 Posts

Posted - 04/24/2014 :  17:09:09  Show Profile  Reply with Quote
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

Turkey
76 Posts

Posted - 04/25/2014 :  07:42:38  Show Profile  Reply with Quote
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

Turkey
76 Posts

Posted - 04/25/2014 :  08:23:33  Show Profile  Reply with Quote
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
  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.06 seconds. Powered By: Snitz Forums 2000