CREATE VIEW [dbo].[pal_vCampaignLog]
AS
SELECT	C.recId ,
        C.campaignTitle ,
        C.campaignBody ,
        T.campaignType ,
        C.isRecurring ,
        C.messageType ,
        C.lastSent ,
        C.nextSend ,
        C.createdBy ,
        C.dateSaved ,
        C.dateUpdated ,
        C.isActive ,
        C.isDraft ,
        C.contactSourceSurface ,
        C.contactNumberField ,
        C.contactNameField ,
        C.filterField ,
        C.filterValue ,
		I.recId intervalId,
        I.interval 
FROM	dbo.pal_Campaign C
		JOIN dbo.pal_CampaignInterval I
			ON I.recId = C.interval
		JOIN dbo.pal_CampaignType T
			ON T.recId = C.campaignType
WHERE	C.recId IN (SELECT campaignId FROM pal_CampaignMessage)

GO


