I solved this by creating a function that first converts each character to its ASCII value and subsequently totals up the values of all the digits in the ASCII representation.
Function as follows:
create function dbo.getAsciiRepresentation
(
@string varchar (max)
)
returns int
as
BEGIN
DECLARE @position int, @aux char(3), @myvalFirst varchar(2000)='1'
DECLARE @intOfVal bigint
declare @total int, @myval varchar(2000)='1'
SET @position = 1
WHILE @position <= DATALENGTH(@string)
BEGIN
SET @aux = ASCII(SUBSTRING(@string, @position, 1))
SET @myvalFirst = @myvalFirst+ replace(@aux,' ','0')
SET @position = @position + 1
END
set @myval = @myvalFirst
set @position = 1
set @total = 0
WHILE @position <= DATALENGTH(@myval)
BEGIN
set @aux = SUBSTRING(@myval, @position, 1)
set @total = @total + cast(@aux as int)
SET @position = @position + 1
END
return @total
END
This will then return the same value as long as the same characters are present, regardless of the order.