Scalar-valued Functions [dbo].[is_different_binary]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@old_valuebinary(16)16
@new_valuebinary(16)16
SQL Script
CREATE FUNCTION dbo.is_different_binary (@old_value binary(16), @new_value binary(16))
RETURNS int
AS
BEGIN
    -- NULL has to be treated separately as comparison results in unknown!
    if @old_value IS NULL
        if @new_value IS NULL
            return 0
        else
            return 1

    if @new_value IS NULL
        return 1

    if @old_value <> @new_value
        return 1
    return 0
END
GO
Uses