Click to See Complete Forum and Search --> : how to write trigger based on certain condition


pra123
11-08-2005, 11:22 AM
One of my table called as 'customertable' contains following fields

customername, emailid, subscriptionendperiod

Example records are:

david, david@john.com, 12/20/2005(mm/dd/yyyy format).

My question is that: Just one month before subscriptionendperiod that is on 11/20/2005(mm/dd/yyyy) an automatic email should go to david@john.com with the message 'Your subscription period ends on 12/20/2005'

How to write trigger for this.

Please Note : No ASP code is invloved in this.
Only MSSQL coding to be done.


Regards

lmf232s
11-08-2005, 01:22 PM
create a .vbs file that will

Hit the Database and look up everyone that meets the criteria you mentioned.

Then for each of those users, send them an email.


After you have your .vbs file created then schedule an event in windows scheduler to run that .vbs file every night, every week, etc. ( when ever you want it to run)

This should do the trick for you.
I have severl automated tasks set up this way, some are automated emails and some are table clean up's and it works great.

pra123
11-09-2005, 03:14 AM
create a .vbs file that will

Hit the Database and look up everyone that meets the criteria you mentioned.

Then for each of those users, send them an email.


After you have your .vbs file created then schedule an event in windows scheduler to run that .vbs file every night, every week, etc. ( when ever you want it to run)

This should do the trick for you.
I have severl automated tasks set up this way, some are automated emails and some are table clean up's and it works great.


Thanks for the reply
Please tell me how to schedule task to run that vbs file in my computer once everynight.
Regards

lmf232s
11-09-2005, 10:18 AM
start/settings/control panel

Select the folder "Scheduled Tasks"
(This is where you will see a list of all Scheduled Tasks on your computer, it should be empty when you go to it, unless you looking at say a server and your admins are running some scripts on it)

Click the Add Scheduled Task, this will open the wizard.

FirstScreen -- Browse to the .vbs file that you want to run and select that.

SecondScreen -- Give it a name and select how often you want it to run (there are more options to come that will let you say, run it every 20 min from 2pm to 3pm on the 1 day of the month etc.)

ThirdScreen -- Select a start time, how ofter to perform the task and a start date.

ForthScreen -- Depending on what this script is going to do, it will need authentication. We run on a doamin so we created a user, well call him AgentScript. AgentScript is set up with permissions that he will need to do things. (will the script need to write files or folders ot differnt servers, delete files, copy files, etc. You need to make sure that the User has the correct permissions)

FifthScreen -- Check the box to "Open advanced properties for this task when i click finish" (this is really just to look at all the things that are available to you, you might not need to set anything else but just take a peek anyway. WHen ever you click on a task to edit it, your going to see this screen anyways but you might as well get familiar with it)

Thats it, youve just scheduled a windows task to run.