Data Profiling with T-SQL

  • mschluper

    Newbie

    Points: 6

    Two more errors I ran into:

    (1) Line 217 and 218 read
    ,MAX(' + QUOTENAME(@COLUMN_NAME) + ')
    ,MIN(' + QUOTENAME(@COLUMN_NAME) + ')
    I propose
    ,MAX(CAST(' + QUOTENAME(@COLUMN_NAME) + ' AS NUMERIC(36,2)))
    ,MIN(CAST(' + QUOTENAME(@COLUMN_NAME) + ' AS NUMERIC(36,2)))
    to avoid exceptions.

    (2) On line 558 a SQL query is constructed, and a cursor is created to complete it. If the cursor yields not records, the SQL query is invalid. So it's better to wrap this in an IF statement, something like
    DECLARE @RecordCount int
    SELECT @RecordCount = COUNT(*)
    FROM #ProfileData
    WHERE NoDistinct < @DistinctValuesMinimum

    IF @RecordCount > 0
    BEGIN
    ... -- original code here (lines 558 - 585)
    END ELSE BEGIN
        INSERT INTO #DomainAnalysis (DomainName, DomainElement, DomainCounter) VALUES ('Too many distinct values - No Analysis', NULL, NULL)
    END

Viewing post 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply