SELECT Camp.ID, Inst.StartDate, detail.CertScopeValue, Actr.Actor, Ctype.CampaignType, 'Cert'+REPLACE(Ctype.CampaignType,' ','') AS mytable FROM CertCampaign Camp LEFT JOIN CertInstance Inst ON Inst.CampaignId=Camp.ID LEFT JOIN CertScope Scope ON Scope.ID=Camp.CertScopeID LEFT JOIN CertScopeDetail detail ON detail.CampaignId=Camp.ID LEFT JOIN CertActor Actr ON Actr.ID=Camp.CertActorId LEFT JOIN CertCampaignType Ctype ON Ctype.ID=Camp.CampaignTypeId LEFT JOIN (SELECT CASE when mytable='CertUserToAccount' then CertUserToAccount)t ON Inst.ID=t.InstanceId (SELECT CASE mytable when 'CertAccountToRole' then LEFT JOIN CertAccountToRole when 'CertAccountToPermission' then LEFT JOIN CertAccountToPermission when 'CertRoleToPermission' then LEFT JOIN CertRoleToPermission when 'CertUserToAccount' then LEFT JOIN CertUserToAccount)TypeName ON Inst.ID=TypeName.InstanceId WHERE Camp.ID='46722DAF-931D-4DBE-9CD6-6FCB1B42FE94' AND detail.CertScopeID=Camp.CertScopeID
CASE WHEN
END
SELECT CASE when mytable='CertUserToAccount' then CertUserToAccount
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)