Dependencies for System Stored Procedure: master.dbo.sp_DBHasChanged

ReferencingFQN ReferencingType ReferencedFQN ReferencedType Depth RedHierarchy
master.dbo.sp_DBHasChanged Stored procedure master.dbo.sp_ExecTemplate Stored procedure 1 [master].[dbo].[sp_ExecTemplate]
master.dbo.sp_ExecTemplate Stored procedure Util.dbo.GetColumnType SQL inline table-valued function 2 [master].[dbo].[sp_ExecTemplate], [Util].[dbo].[GetColumnType]
master.dbo.sp_ExecTemplate Stored procedure Util.dbo.ParseSPDefaults Assembly (CLR) table-valued function 2 [master].[dbo].[sp_ExecTemplate], [util].[dbo].[ParseSPDefaults]
master.dbo.sp_ExecTemplate Stored procedure Util.dbo.PrintLargeText Stored procedure 2 [master].[dbo].[sp_ExecTemplate], [Util].[dbo].[PrintLargeText]
master.dbo.sp_ExecTemplate Stored procedure Util.dbo.StringConcat Aggregate function (CLR) 2 [master].[dbo].[sp_ExecTemplate], [Util].[dbo].[StringConcat]
Util.dbo.ParseSPDefaults Assembly (CLR) table-valued function Util.UtilClr ASSEMBLY 3 [master].[dbo].[sp_ExecTemplate], [util].[dbo].[ParseSPDefaults], [Util].[UtilClr]
Util.dbo.PrintLargeText Stored procedure Util.dbo.PrintLargeText_CLR Assembly (CLR) stored-procedure 3 [master].[dbo].[sp_ExecTemplate], [Util].[dbo].[PrintLargeText], [Util].[dbo].[PrintLargeText_CLR]
Util.dbo.StringConcat Aggregate function (CLR) Util.UtilClr ASSEMBLY 3 [master].[dbo].[sp_ExecTemplate], [Util].[dbo].[StringConcat], [Util].[UtilClr]

System Stored Procedure: master.dbo.sp_DBHasChanged

USE master
GO
IF OBJECT_ID('sp_DBHasChanged') IS NULL EXEC ('CREATE PROCEDURE sp_DBHasChanged AS SELECT 1 AS ID')
GO
ALTER PROCEDURE dbo.sp_DBHasChanged
    @DatabaseName VARCHAR(256) = NULL,
    @StartDateTime DATETIME = NULL,
    @EndDateTime DATETIME = NULL,
    @ChangeCount INT OUTPUT
AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
IF @DatabaseName IS NULL
    OR @StartDateTime IS NULL
    BEGIN
        EXEC master.dbo.sp_ExecTemplate
            @ObjectName = 'sp_DBHasChanged',
            @PrintDefault = 0,
            @DeclareReturn = 0,
            @PrintReturnLine = 0,
            @DoNotDeclareVar = 1
        RETURN
    END
SELECT  @ChangeCount = NULL,
        @EndDateTime = ISNULL(@EndDateTime, GETDATE())
IF DB_ID(@DatabaseName) IS NULL
    RETURN
IF (SELECT  CONVERT(INT, value_in_use)
    FROM    sys.configurations (NOLOCK)
    WHERE   name = 'default trace enabled') = 1
    BEGIN
        BEGIN TRY
            DECLARE @curr_tracefilename VARCHAR(500) ;
            DECLARE @base_tracefilename VARCHAR(500) ;
            DECLARE @indx INT ;

            SELECT  @curr_tracefilename = PATH
            FROM    sys.traces (NOLOCK)
            WHERE   is_default = 1 ;
            SET @curr_tracefilename = REVERSE(@curr_tracefilename) ;

            SELECT  @indx = PATINDEX('%\%', @curr_tracefilename) ;
            SET @curr_tracefilename = REVERSE(@curr_tracefilename) ;

            SET @base_tracefilename = LEFT(@curr_tracefilename, LEN(@curr_tracefilename) - @indx) + '\log.trc' ;

            SELECT  @ChangeCount = COUNT(*)
            FROM    ::
                    FN_TRACE_GETTABLE(@base_tracefilename, DEFAULT) t
            INNER JOIN sys.trace_events TE (NOLOCK) ON T.EventClass = TE.trace_event_id
            WHERE   DatabaseID = DB_ID(@DatabaseName)
                    AND StartTime >= @StartDateTime
                    AND StartTime < @EndDateTime
                    AND te.Name IN ('Object:Created', 'Object:Altered', 'Object:Deleted')
        END TRY
        BEGIN CATCH
        END CATCH
    END
GO
EXEC sys.sp_ms_marksystemobject sp_DBHasChanged
GO

Description for System Stored Procedure: master.dbo.sp_DBHasChanged

Todo
Site Map | Printable View | © 2008 - 2012 NuRoN Consulting, INC | Powered by mojoPortal | HTML 5 | CSS | Original design by Andreas Viklund
Share This Using Popular Bookmarking Services