Limiting access to a view based on time frame

  • Is is possible to grant Select right to a view, and then limit that right to a time frame, such as 9 AM to noon? 

    Thanks,

    Arthur

     

  • Arthur

    Not as far as I know.  Although you could change the view to a stored procedure, and put some conditional logic in that.

    John

  • Hi Its 2.45 pm here, I get results from klh1 and nothing from klh2.  The trick is that each predicate must be true, therefore we can limit by time of day

    create view klh1 as

     select *

     from contact_details

     where username like 'a%'

       and  datepart(hh, getdate()) between 12 and 15

    create view klh2 as

     select *

     from contact_details

     where username like 'a%'

       and  datepart(hh, getdate()) between 1 and 5

     

    Regards

    Karl

  • Thank you, both of you.  Both solutions offer good possibilities. 

    "User", not "Username" works for me.  Using datepart() is very simple and works nicely. 

     

    Arthur

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply