ALTER PROCEDURE [dbo].[VCT_SP_SUBJECT_EMAIL_REMINDER]
AS
CREATE TABLE #tempEstimatedDates(
SUBJECT_ID int,
FIRST_NAME varchar(200),
LAST_NAME varchar(200),
MIDDLE_NAME varchar(200),
EMAIL_ID varchar(200),
ACTIVITY_VALUE datetime,
SUB_VISIT_ID int,
VISIT_NO INT,
VISIT_DETAIL_ID INT,
PROTOCOL_ID INT,
LOCATION_ID INT,
SITE_ID INT,
SITE_NAME VARCHAR(200),
PROTOCOL_NAME VARCHAR(200)
)
INSERT INTO
#tempEstimatedDates(SUBJECT_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME,EMAIL_ID,
ACTIVITY_VALUE,
SUB_VISIT_ID,VISIT_NO,VISIT_DETAIL_ID,PROTOCOL_ID
,LOCATION_ID,PROTOCOL_NAME,SITE_ID,SITE_NAME)
SELECT * FROM dbo.[GET_SUBJECT_SCHEDULE]('Estimated Date Of Next Visit')
---TABLE FOR ACTUAL DATE OF VISIT---
CREATE TABLE #tempActualDates(
SUBJECT_ID int,
FIRST_NAME varchar(200),
LAST_NAME varchar(200),
MIDDLE_NAME varchar(200),
EMAIL_ID varchar(200),
ACTIVITY_VALUE datetime,
SUB_VISIT_ID int,
VISIT_NO INT,
VISIT_DETAIL_ID INT,
PROTOCOL_ID INT,
LOCATION_ID INT,
SITE_ID INT,
SITE_NAME VARCHAR(200),
PROTOCOL_NAME VARCHAR(200)
)
INSERT INTO
#tempActualDates(SUBJECT_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME,EMAIL_ID,
ACTIVITY_VALUE,SUB_VISIT_ID,
VISIT_NO,VISIT_DETAIL_ID,PROTOCOL_ID ,LOCATION_ID,PROTOCOL_NAME,SITE_ID,SITE_NAME)
SELECT * from dbo.[GET_SUBJECT_SCHEDULE]('Actual Date Of Visit')
select * from #tempEstimatedDates
where subject_id in
(select subject_id from #tempActualDates) and visit_no not in (select visit_NO from
#tempActualDates)
AND
( convert(varchar,ACTIVITY_VALUE,101)=convert(varchar,getdate(),101)
or dateadd(d,2,convert(varchar,getdate()
,101))=convert(varchar,ACTIVITY_VALUE,101)
or dateadd(d,1,convert(varchar,getdate() ,101))=convert(varchar,ACTIVITY_VALUE,101)
)
UNION
select * from #tempEstimatedDates
where subject_id NOT in
(select subject_id from #tempActualDates)
AND
( convert(varchar,ACTIVITY_VALUE,101)=convert(varchar,getdate(),101)
or dateadd(d,2,convert(varchar,getdate()
,101))=convert(varchar,ACTIVITY_VALUE,101)
or dateadd(d,1,convert(varchar,getdate() ,101))=convert(varchar,ACTIVITY_VALUE,101)
)
select * from #tempEstimatedDates
where subject_id in
(select subject_id from #tempActualDates) and visit_no not in (select visit_NO from
#tempActualDates)
AND
( --convert(varchar,ACTIVITY_VALUE,101)=convert(varchar,getdate(),101) or
DATEDIFF(d,convert(varchar,ACTIVITY_VALUE,101),convert(varchar,getdate()
,101))=2
or DATEDIFF(d,convert(varchar,ACTIVITY_VALUE,101),convert(varchar,getdate()
,101))=1
)
UNION
select * from #tempEstimatedDates
where subject_id NOT in
(select subject_id from #tempActualDates)
AND
( --convert(varchar,ACTIVITY_VALUE,101)=convert(varchar,getdate(),101) OR
DATEDIFF(d,convert(varchar,ACTIVITY_VALUE,101),convert(varchar,getdate()
,101))=2
or DATEDIFF(d,convert(varchar,ACTIVITY_VALUE,101),convert(varchar,getdate()
,101))=1
)
drop table #tempEstimatedDates
drop table #tempActualDates
這是我的存儲過程,它在sql server中返回兩個數據表。但是,當我拖放這個SP在dbml中,它的返回類型變成了int而不是Isingleresult。如何解決這個問題呢。返回整數而不是ISingleResult的存儲過程
請給我一些想法,比如如何爲此製作UDF – 2011-06-03 08:00:11
對不起,我真的不記得了。你應該能夠谷歌如何創建UDF的。一旦你創建了它,你就可以將它添加到你的.dbml文件中,就像你使用SP一樣。 – simonlchilds 2011-06-06 08:55:17