我正在使用这种语法,如果它没有出错,它应该可以正常工作。
SELECT
e.user_key,
e.char_key,
CONVERT(VARCHAR,substring(e.char_data, 9, 16)) AS name,
p.CHAR_DATA
FROM
CHAR_DATA0 AS e
INNER JOIN
CHAR_DATA1 AS p ON e.CHAR_KEY = p.CHAR_KEY
WHERE
p.CHAR_DATA LIKE '%'+CAST(cast(reverse(CONVERT(BINARY, 9998)) as BINARY(2)) AS BINARY(2))+'%'
ORDER BY
char_key
我需要帮助。如何更改此代码以使其正常工作?
CHAR_DATA
列是类型BINARY(2000)
我有这样的数据:(使用选择获得)
0x04005C03020F2789080100000F278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBA3B8C08000000BB3B8C080000000F2789080100000F278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBC3B8C08000000BD3B8C080000000F2789080100000F278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBE3B8C08000000BF3B8C080000000F2789080100000F278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFC03B8C08000000C13B8C08000000B5388B08020000B5388B08020000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBA3B8C08000000BB3B8C08000000B5388B08020000B5388B08020000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBC3B8C08000000BD3B8C080000000E2789080100000E278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFBE3B8C08000000BF3B8C080000000E2789080100000E278908010000FFFFFFFFFFFFFF0E2787080100000E278708010000FFFFFFFFFFFFFFC03B8C08000000C13BFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0F27FFFF0100000F27FFFF0100000E2789080000000E278908000000FFFFFFFFFFFFFF7E107F08000000EC168408000000B0177D080000000F27FFFF0100000F27FFFF0100000E2789080000000E27890800000052167C081E000052167C081E0000E2167D08000000271F2005000000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0E2787080100000E27870801000052167C081E000052167C081E0000FFFFFFFFFFFFFF13127F08000000C813FFFF1E0000C813FFFF1E00000E2787080100000E27870801000028127A08000000BF3B2D05000000FFFFFFFFFFFFFF13127F08000000C813FFFF1E0000C813FFFF1E0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF28127A08000000FFFFFFFFFFFFFF1B1A80081A00001B1A80081A0000E915FFFF1B0000E915FFFF1B000023067A0800000024147B0800000020120D05000000084792080100001B1A80081A00001B1A80081A0000E915FFFF1B0000E915FFFF1B000025067A0800000024147B0800000020120D05000000E21610050000000000009D000000FFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
如果其中包含我要查找的条目,我需要在这些行中的某个位置进行搜索。
我要查找的始终是 2 个字节。所以我在上面的语法中寻找 0x0E27 。
这是一种有效的语法,但不是我想要做的:
SELECT
CONVERT(INT,cast(reverse(substring(char_data, 37, 2)) as BINARY(2))) AS helm
FROM CHAR_DATA0
WHERE CHAR_KEY = 5
另一个是如果我使用 nvarchar(MAX) 它给出的结果甚至不包含我要查找的数据。