USP_PDACCOUNTSEGMENTMAPPINGVIEW_RECREATE
Alters PDACCOUNTSEGMENTMAPPINGVIEW when account segments are added or deleted
Definition
Copy
CREATE procedure [dbo].[USP_PDACCOUNTSEGMENTMAPPINGVIEW_RECREATE]
as
begin
declare @string varchar(max)
select @string = ISNULL(@string+' UNION ','') + 'SELECT '+DESCRIPTIONCOLUMNNAME+' AS LONGDESCRIPTION, ID as LONGDESCRIPTIONID, convert(uniqueidentifier,'''+ convert(char(36),B.id )+ ''') as PDACCOUNTSTRUCTUREID FROM '+TableName + case a.ID when '2C64A221-99F9-46F3-B35B-F3E34A3AA484' then ' where programid is null' else '' end
FROM dbo.PDACCOUNTTABLESAVAILABLEFORSEGMENT as a join dbo.PDACCOUNTSTRUCTURE as b on a.ID = b.PDACCOUNTTABLESAVAILABLEFORSEGMENTID where b.SEGMENTTYPE = 3
if not @string is null
exec( 'ALTER VIEW dbo.PDACCOUNTSEGMENTMAPPINGVIEW as '+@string)
else
exec( 'ALTER VIEW dbo.PDACCOUNTSEGMENTMAPPINGVIEW as select '''' as LONGDESCRIPTION, ID as LONGDESCRIPTIONID, newid() as PDACCOUNTSTRUCTUREID from dbo.EVENT where ID = ''00000000-0000-0000-0000-000000000000''' )
end