Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 datepart script

Author  Topic 

propanecan
Yak Posting Veteran

60 Posts

Posted - 2007-04-17 : 21:28:26
I'm trying to use a script that will only execute between the hours of 6am and 6pm. The statement is as follows:

IF DATEPART (HOUR, (GETDATE())) BETWEEN 6 AND 18

BEGIN TRANSACTION

The command seems to execute regardless of what time it is. Any ideas?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-17 : 22:06:29
enclose it in BEGIN . .. END

IF DATEPART (HOUR, (GETDATE())) BETWEEN 6 AND 18
BEGIN
<your script here>
END



KH

Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-04-17 : 22:09:18
what exactly are you trying to do? You could create a job and schedule it to run appropriately.
A script like this will run when you execute it but not on a recurring basis..


************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -