Solved

SQL SERVER 2005 Daily Job

Posted on 2007-03-27
1
224 Views
Last Modified: 2007-03-27
Hello -how would I set up to run this script everyday at 8:00am on a SQL Server 2005

Thanks JK




IF EXISTS (SELECT 1 FROM Settlement WHERE
DateStampTxt <= CAST(CONVERT(varchar,GETDATE() -1, 112) AS DATETIME) and Sitetxt = 2 and PrimaryKey = (Select Max(PrimaryKey) from Settlement where SiteTxt=2))
BEGIN
declare @body1 varchar(100)
set @body1 = ' ELLENGTON HAS NOT SUBMITED A NIGHT AUDIT'
EXEC msdb.dbo.sp_send_dbmail @recipients='test@test.com',
    @subject = 'Night Audit',
    @body = @body1,
    @body_format = 'HTML';
END
0
Comment
Question by:fsuedu
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 18801217
you need to create a job for this purpose

http://msdn2.microsoft.com/en-us/library/ms186273.aspx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now