title: How to generate alert from stored procedure which can be received in SQL Server agent in SQL Server 2012
body: <p>I am new to SQL Server and I have been assigned a task to generate alert using stored procedure in SQL SErver which are based on some logic for example if the value of speed column in my table is over 90 it should generate an alert message "you are over speeding " and it should be sent via email with help of SQL Server agent and database mail. </p>
  
  <p>I have read some article but still not clear how to generate some user defined error from a stored procedure in SQL Server and how to log it in error log and with help of that my SQL Server agent recognise that error number and generate this message via mail. </p>
  
  <p>If anyone has any idea about this please help. Thanks in advance.</p>