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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 condition

Author  Topic 

GaneshRamanan
Starting Member

40 Posts

Posted - 2011-01-12 : 05:10:23
sp 1

[OPM].[AppointmentExtend](@DoctorID Varchar(5),@AppointmentDate Datetime,@FromTime datetime,@ToTime Datetime)


opm.appointmentextend fromtime totime appointmenttime

2011-01-12 11:03 2011-01-12 11:06 1900-01-01 00:03:00

doing computation in this sp to split fromtime, totime, based on appointmenttime

sp 2
[OPM].[appointmentExtension](@doctorid Varchar(5),@appointmentdate datetime,@specialistid int,@fromtime datetime,@totime datetime,@userid bigint)

Create table #TmpScheduleDetail(ID int ,FromTime datetime,AppointmentTime datetime,ToTime datetime,Status varchar(5));
insert into #TmpScheduleDetail Exec [OPM].[AppointmentExtend] @DoctorID,@AppointmentDate,@FromTime,@ToTime


i need to restrict the rows

1. If the @fromtime between 11:00 and 12:00 which is already returned in sp1 i dont want to return it from sp1

how can i check this condition in sp1

can anyone pls give an idea

Thanks in advance,
Ganesh Ramanan

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-12 : 05:15:06
do both procedures return same columns?
Go to Top of Page

GaneshRamanan
Starting Member

40 Posts

Posted - 2011-01-12 : 05:21:34
No,

SP2 Insert the values into the Appointment tables

SP1 RETURNS VALUES TO THE SP2
SP2 INSERT THOSE VALUES INTO TABLES

but i m getting fromtime, totime in sp2

SP2 passes the values to the SP1

I want to restrict the values which is already inserted into the appointment tables

Thanks
Ganesh
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-12 : 06:13:56
Following highlighted statements are confusing for me

SP1 RETURNS VALUES TO THE SP2
SP2 INSERT THOSE VALUES INTO TABLES

but i m getting fromtime, totime in sp2

SP2 passes the values to the SP1


doesn't make sense to me .. however you can simply restrict it via using "not Exist" or "Exist" in the where clause, while inserting it into the target table!

e.g.
Insert into tableName (Column Names)
Select columnNames from TableName1
where not exists (select 1 from TableName2 where startTime=TableName1.StartTime and endTime=TableName1.Endtime)

etc




Go to Top of Page

GaneshRamanan
Starting Member

40 Posts

Posted - 2011-01-13 : 01:49:44
Thanks Mik for your support
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-13 : 07:09:58
you are welcome!
Go to Top of Page
   

- Advertisement -