I'm seeing an strange behaviour when performining varbinary concatenation as per the following test case: Is there a bug or do I need to use another function?
declare @l_header varbinary(32) declare @l_BASE varbinary(28) = 0x5800355E01EE35C1355E01EED70700000001FF00FF00FFFFFFFFFFFF; declare @l_SEQ#BIN VARBINARY(4) SET @l_SEQ#BIN = convert(varbinary(4), 1055); SET @l_header = @l_BASE + @l_SEQ#BIN select LEN(@l_BASE) AS BASE_LEN, LEN(@l_SEQ#BIN) AS SEQ#BIN_LEN, len(@l_header) AS HEADER_LEN, @l_SEQ#BIN AS SEQ#BIN SET @l_SEQ#BIN = convert(varbinary(4), 1056); SET @l_header = @l_BASE + @l_SEQ#BIN select LEN(@l_BASE) AS BASE_LEN, LEN(@l_SEQ#BIN) AS SEQ#BIN_LEN, len(@l_header) AS HEADER_LEN, @l_SEQ#BIN AS SEQ#BIN
BASE_LEN SEQ#BIN_LEN HEADER_LEN SEQ#BIN
28 4 32 0x0000041FBASE_LEN SEQ#BIN_LEN HEADER_LEN SEQ#BIN
28 3 31 0x00000420