question

user-1191 (yahoo) avatar image
user-1191 (yahoo) asked

Should I use a Stored Procedure?

I am creating an asp.net web application that will help managers and tutors track the schedule of a certain students current asessments. What I need the database to do is flag up when a student is behind on a particular module and then email their tutor this information perhaps a week before the due date?

Am I correct in thinking that I would use a stored procedure to extract this information?

If so could anyone point me in the direction of some sample code or resources that will get me on the right track?

Thanks in advance...

sql-server-2008datetime
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jason Cumberland avatar image
Jason Cumberland answered

I'm not sure what you mean by "flag up" here. You will need to write a query that returns values when the "a student is behind on a particular module" condition is met and then if there are results from the query then email out using sp_send_dbmail. You could easily use a procedure to do this but you will have to come up with a calling method, either a SQL Agent job or a some other process that executes the procedure.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jay D avatar image
Jay D answered

I agree with Jason. Creating an SQL Agent job that runs the procedure once daily seems like it should do the trick. See Books Online for more information on the syntax and steps necessary to create a SQL Agent job. sp_add_job and related information is found at http://msdn.microsoft.com/en-us/library/ms182079.aspx

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.