Procedure: [AdventureWorks2016CTP3].[dbo].[AUDIT_prc_Analyze]

CollapseAll image

Collapse image Procedure properties


 Name   Value 
 Schema   [dbo] 
 Owner   [dbo] 
 Creation date   21.09.2016 
 Type   P 
 Encrypted   
 ID   1435868182 
 Implementation type   Transact SQL 
 Is native compiled   

Collapse image Creation options


Name Value
QUOTED_IDENTIFIER ON
ANSI_NULLS ON

Collapse image Parameters


Name  Description Datatype  Max length  Type  ReadOnly
@DDL   bit 1 Input/output or output  
@Identity   bit 1 Input/output or output  
@View   bit 1 Input/output or output  
@standard   bit 1 Input/output or output  
@aggregate   bit 1 Input/output or output  
@ddl_report   bit 1 Input/output or output  
@purge   bit 1 Input/output or output  
@undo   bit 1 Input/output or output  
@Delete   bit 1 Input/output or output  
@Analyze   bit 1 Input/output or output  

Collapse image Objects that depend on [dbo].[AUDIT_prc_Analyze]


Object name Object type Dep level
[dbo].[AUDIT_prc_DeleteArchitecture] Procedure 1
Total 1 object(s)

Collapse image SQL


SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE dbo.AUDIT_prc_Analyze
    @DDL          bit    output,
    @Identity     bit    output,
    @View          bit    output,
    @standard     bit    output,
    @aggregate     bit    output,
    @ddl_report    bit    output,
    @purge          bit    output,
  @undo          bit    output, -- Retained for compatibility with previous architecture 
    @Delete        bit    output,
    @Analyze    bit    output
as
    declare @cmptlvl int
    set @Identity=1 --now always
    Select @cmptlvl = t1.cmptlevel 
        from master.dbo.sysdatabases t1
        where t1.[name]=DB_NAME()
    --    DDL
    set @DDL=1    
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingEnd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingEnd is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingStart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingStart is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingAddFilterValue]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingAddFilterValue is Missing'
        END
        if NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_LOG_DATA]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
        BEGIN
            set @DDL = 0
            PRINT '     AUDIT_LOG_DATA is Missing'
        END
        if NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_LOG_TRANSACTIONS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
        BEGIN
            set @DDL = 0
            PRINT '     AUDIT_LOG_TRANSACTIONS is Missing'
        END
        IF @cmptlvl > 70
        BEGIN
        IF OBJECTPROPERTY(OBJECT_ID('dbo.AUDIT_fn_HexToStr'), 'IsScalarFunction') IS NULL 
        BEGIN
            set @DDL = 0
            PRINT '     dbo.AUDIT_fn_HexToStr is Missing'
        END
        IF OBJECTPROPERTY(OBJECT_ID('dbo.AUDIT_fn_SqlVariantToString'), 'IsScalarFunction') IS NULL
        BEGIN
            set @DDL = 0
            PRINT '     dbo.AUDIT_fn_SqlVariantToString is Missing'
        END
        END
                IF @DDL = 0 
                BEGIN
                    PRINT 'Internal DDL Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Internal DDL Script(s) OK'
                END
    --    Indentity
    set @View = 1
        if NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_VIEW]') and OBJECTPROPERTY(id, N'IsView') = 1)
        BEGIN
            set @View = 0
            PRINT '     AUDIT_VIEW is Missing'
        END
                    IF @View = 0 
                    BEGIN
                        PRINT 'Audit View Script(s) Missing or Incomplete'
                    END
                    ELSE
                    BEGIN
                        PRINT 'Audit View Script(s) OK'
                    END
    set @aggregate = 1
        if NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_AggregateReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @aggregate  = 0
            PRINT '     AUDIT_prc_AggregateReport is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingStart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @aggregate  = 0
            PRINT '     AUDIT_prc_ReportingStart is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingEnd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @aggregate  = 0
            PRINT '     AUDIT_prc_ReportingEnd is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingAddFilterValue]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @aggregate  = 0
            PRINT '     AUDIT_prc_ReportingAddFilterValue is Missing'
        END
                IF @aggregate = 0 
                BEGIN
                    PRINT 'Aggregate Reporting Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Aggregate Reporting Script(s) OK'
                END
    set @standard = 1
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_StandardReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard = 0
            PRINT '     AUDIT_prc_StandardReport is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingEnd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingEnd is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingStart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingStart is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingAddFilterValue]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @standard  = 0
            PRINT '     AUDIT_prc_ReportingAddFilterValue is Missing'
        END
                IF @standard = 0 
                BEGIN
                    PRINT 'Standard Reporting Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Standard Reporting Script(s) OK'
                END
    set @ddl_report = 1
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_DDLReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @ddl_report = 0
            PRINT '     AUDIT_prc_DDLReport is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingEnd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @ddl_report  = 0
            PRINT '     AUDIT_prc_ReportingEnd is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingStart]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @ddl_report  = 0
            PRINT '     AUDIT_prc_ReportingStart is Missing'
        END
        if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_ReportingAddFilterValue]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @ddl_report  = 0
            PRINT '     AUDIT_prc_ReportingAddFilterValue is Missing'
        END
                IF @ddl_report = 0 
                BEGIN
                    PRINT 'DDL Reporting Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'DDL Reporting Script(s) OK'
                END
    set @purge = 1
        if NOT exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_Purge_AUDIT_LOG]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @purge = 0
            PRINT '     AUDIT_prc_Purge_AUDIT_LOG'
        END
                IF @purge = 0 
                BEGIN
                    PRINT 'Audit Data Purge Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Audit Data Purge Script(s) OK'
                END
    set @Delete = 1
        if NOT EXISTS (select * from dbo.sysobjects where name = 'AUDIT_prc_DeleteArchitecture')
        BEGIN            
            set @Delete = 0
            PRINT '     AUDIT_prc_DeleteArchitecture is Missing'
        END
                IF @Delete = 0 
                BEGIN
                    PRINT 'Delete Architecture Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Delete Architecture Script(s) OK'
                END
    set @Analyze = 1
        if NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[AUDIT_prc_Analyze]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
        BEGIN
            set @Delete = 0
            PRINT '     AUDIT_prc_Analyze is Missing'
        END
                IF @Analyze = 0 
                BEGIN
                    PRINT 'Analyze Script(s) Missing or Incomplete'
                END
                ELSE
                BEGIN
                    PRINT 'Analyze Script(s) OK'
                END
GO

Collapse image See also


List of procedures