Thursday, August 20, 2009

Check whether the time slot is availble?

We face the problem to do some time based or reservation , to check whether the time slot is available or not.

This script will help to do it better and quicker.

Declare @mytable table (id int,fromtime smalldatetime,totime smalldatetime)

insert into
@mytable values (1,'2009-08-20 08:00:00','2009-08-20 12:00:00')

if not exists (select 'x' from
@mytable where '2009-08-20 07:00:00' between fromtime and totime)

print 'Insert statement'


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.