HASHBYTES ERROR INT

  • I get in the following sql statement a ERROR:

    SELECT *

    INTO [#VWDimLocation]

    FROM DWH_Staging.[Staging].[VWDimLocation]

    ;

    CREATE UNIQUE CLUSTERED INDEX UpdateSource_AK

    ON [#VWDimLocation] ( [LocationCode]

    , [DataAreaID]

    , [SourceCode]

    )

    ;

    SELECT [LocationCode]

    , [DataAreaID]

    , [SourceCode]

    , [LocationName]

    , [LocationType]

    , [City]

    , [CountryCode]

    , [CountryName]

    , HASHBYTES('MD5',ISNULL([LocationName],'')+ ISNULL([LocationType],'')+ ISNULL([City],'')+ ISNULL([CountryCode],'')+ ISNULL([CountryName],'')+ '00') AS [CheckSum]

    , HASHBYTES('MD5',ISNULL([LocationName],'')+ ISNULL([LocationType],'')+ ISNULL([City],'')+ ISNULL([CountryCode],'')+ ISNULL([CountryName],'')) AS [CheckSumSCD1]

    , HASHBYTES('MD5','') AS [CheckSumSCD2]

    ,1 AS [IsActual]

    ,0 AS [IsInferred]

    ,0 AS [IsDeleted]

    ,SYSDATETIME() AS [EffectiveDate]

    ,'31-DEC-9999' AS [ExpiryDate]

    ,SYSDATETIME() AS [InsertDateTime]

    ,SYSDATETIME() AS [UpdateDateTime]

    ,1 AS [BatchID]

    ,1 AS [ProcessLogID]

    FROM [#VWDimLocation];

    Im Using BIML to generate the packages with SQL statement. Mabye i can fi this manual but i can not see the error.

    Msg 8116, Level 16, State 1, Line 12

    Argument data type int is invalid for argument 2 of hashbytes function.

  • Quick suggestion, cast all the non varchar columns to varchar before the concatenation.

    😎

  • Tnx for quick reaction.. There was a diffrence in the view colm and my table 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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