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.
| Author |
Topic |
|
Kavitha_BE
Starting Member
1 Post |
Posted - 2009-08-20 : 02:30:13
|
| hi..i want to write a query. suppose the table contains records for dated 2009-08-20 and time between 8:00 to 12:00. and again if trying to insert data for same date in between 9:00 to 10:00 means it should not allow.. so before inserting the query has to check if there is any data in that time.it similar to check whether doctor is free in between time slots to get an doctor appointment.Thanks in advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-20 : 02:43:55
|
how do you stored the appointment time in the table ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-08-20 : 02:46:32
|
| try thiscreate table #mytable (id int,fromtime smalldatetime,totime smalldatetime) insert into #mytable values (1,'2009-08-20 08:00:00','2009-08-20 12:00:00')select * from #mytableif not exists (select 'x' from #mytable where '2009-08-20 07:00:00' between fromtime and totime)begin-- Insert print 'Insert statement'EndSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|