3
I would like to know a way to create a trigger
in sql-server to restrict the time of handling a table between two working days (8:00 to 18:00).
3
I would like to know a way to create a trigger
in sql-server to restrict the time of handling a table between two working days (8:00 to 18:00).
0
It is possible yes. Below a code that does this, extracted from Limit user access to a Certain time.
CREATE TRIGGER usrLoginCheck_LogonTrigger
ON ALL SERVER WITH EXECUTE AS 'batchid'
FOR LOGON
AS
BEGIN
declare @EarlyTime datetime,
@LateTime datetime,
@todays_date varchar(25)
set @todays_date = CONVERT(varCHAR(25),GETDATE(),110)
set @EarlyTime = Convert(datetime, @todays_date + ' 07:00:00.000')
set @LateTime = Convert(datetime, @todays_date + ' 23:00:00.000')
if ORIGINAL_LOGIN()= 'batchid'
and getdate() between @EarlyTime and @LateTime
ROLLBACK;
END
Thank you very much. It would be possible to explain some of the code?
Browser other questions tagged sql-server trigger
You are not signed in. Login or sign up in order to post.
I voted because I left the question open, because the question, although simple and broad-based, can rather be answered and quite interesting.
– Guilherme Nascimento