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 |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2001-12-29 : 10:58:30
|
| I have a list of appointments below. I am sending a cldate(start) and a cldatend(end) date against this table.ie. 2001-12-28 08:00:00, 2001-12-28 09:00:00I want to return only the available resid(resources) as a client selection.I have also included part of the sproc to show you whereI am at. Any suggestions to keep the performance at a maximum would be appreciated.closeid resid cldate cldateend ------- ----------- ------------------------ ---------------------1 1 2001-12-28 08:00:00 2001-12-28 09:00:002 2 2001-12-28 08:00:00 2001-12-28 10:00:003 5 2001-12-28 08:30:00 2001-12-28 12:00:004 12 2001-12-28 12:00:00 2001-12-28 13:00:005 1 2001-12-28 13:00:00 2001-12-28 14:00:006 2 2001-12-28 15:00:00 2001-12-28 16:00:007 1 2001-12-28 17:00:00 2001-12-28 18:00:008 12 2001-12-28 19:00:00 2001-12-28 20:00:009 5 2001-12-28 21:00:00 2001-12-28 22:00:0010 12 2001-12-28 07:00:00 2001-12-28 10:00:00ALTER PROCEDURE s_cal_clos_assing_pag(@oid int,@closeid int, --this is the selected order the client wants to schedule@ddate smalldatetime)asSET NOCOUNT ON--get all available resources for office--set varsdeclare @excludedatestart smalldatetimedeclare @excludedateend smalldatetimeDECLARE @resources table ( recnum int identity (1,1), resid int, tableid int, label varchar(30) )DECLARE @exclude table ( resid int )--set resource id(these are the dates I check table with)set @resid=(select resid from tblorder_close where closeid=@closeid)set @excludedatestart=(select cldate from tblorder_close where closeid=@closeid)set @excludedateend=(select cldateend from tblorder_close where closeid=@closeid)--grab all resources for this office(people)insert @resourcesselect a.resid, b.tableid, b.labelfrom tblresource_join ainner join tblresource b on a.resid=b.residwhere a.oid=@oid --insert into exclude(THIS IS WHERE I NEED HELP)--I need to get all my resources and then exclude the ones that--have appointments between @excludedatestart and @excludedateend timesinsert @excludeselect residfrom tblorder_closewhere @excludedatestart not between cldate and cldateend or @excludedateend not between cldate and cldateend--set return rsslow down to move faster... |
|
|
|
|
|