CREATE_OR_DROP_DIM_CONSTITUENTDEMOGRAPHIC_INDICES

Parameters

Parameter Parameter Type Mode Description
@CREATE_OR_DROP bit IN

Definition

Copy

CREATE procedure [BBDW].[CREATE_OR_DROP_DIM_CONSTITUENTDEMOGRAPHIC_INDICES]
  @CREATE_OR_DROP bit --1 to create, 0 to drop.
  as
  set nocount on;

  if @CREATE_OR_DROP is null
  raiserror('@CREATE_OR_DROP must be 1 or 0 in [BBDW].[CREATE_OR_DROP_DIM_CONSTITUENTDEMOGRAPHIC_INDICES]',16,10);

  if @CREATE_OR_DROP =1
  begin
  --create

    if  [BBDW].[UFN_INDEXEXISTS]('IX_DIM_CONSTITUENTDEMOGRAPHIC_CONSTITUENTDEMOGRAPHIC') = 0
      create nonclustered index [IX_DIM_CONSTITUENTDEMOGRAPHIC_CONSTITUENTDEMOGRAPHIC] on [BBDW].[DIM_CONSTITUENTDEMOGRAPHIC] ([CONSTITUENTRELIGIONCODESYSTEMID],[CONSTITUENTINCOMECODESYSTEMID],[CONSTITUENTTARGETCODESYSTEMID]) with (DATA_COMPRESSION = PAGE) on [BBRPT_DIMIDXGROUP]      

    if  [BBDW].[UFN_INDEXEXISTS]('IX_DIM_CONSTITUENTDEMOGRAPHIC_SOURCEDIMID') = 0
      create nonclustered index [IX_DIM_CONSTITUENTDEMOGRAPHIC_SOURCEDIMID] on [BBDW].[DIM_CONSTITUENTDEMOGRAPHIC] ([SOURCEDIMID]) with (DATA_COMPRESSION = PAGE) on [BBRPT_DIMIDXGROUP];      

  end
  else
  begin
  --drop

    if  [BBDW].[UFN_INDEXEXISTS]('IX_DIM_CONSTITUENTDEMOGRAPHIC_CONSTITUENTDEMOGRAPHIC') = 1
     drop index [IX_DIM_CONSTITUENTDEMOGRAPHIC_CONSTITUENTDEMOGRAPHIC] on [BBDW].[DIM_CONSTITUENTDEMOGRAPHIC]; 

    if  [BBDW].[UFN_INDEXEXISTS]('IX_DIM_CONSTITUENTDEMOGRAPHIC_SOURCEDIMID') = 1
     drop index [IX_DIM_CONSTITUENTDEMOGRAPHIC_SOURCEDIMID] on [BBDW].[DIM_CONSTITUENTDEMOGRAPHIC]; 

  end