I've got a table which contains a varchar(1024) field, which in that contains strings which has hex encoded strings. This table is filled automatically and I have to provide an SP to allow users to download this, therefore, I need to change the hex back into human readable form. If I manually run this statement (taking the Hex data from the field), it works just fine:
But I cannot find a working example of getting this to work when calling the field/column name. I've found a few examples, but these just return a null or 0. I've tried X and UnHex() and neither give me a result. Where am I going wrong? Thanks EDIT: Okay, after doing a bit more testing, it appears it must be the way it's being written to the database in the first place. It's a Classic ASP page that calls an SP, which creates the database entry. In this method, the write to the DB works, and I can see the HEX content in the field. Copying the content of the field, and putting this into a Select X'123123' gives me the ASCII values, as I want. If I try this as a Select, this fails, giving me a zero or Null return.
returns:
Still confused! :) Menambah jawaban oleh ThaBadDawg, gunakan fungsi-fungsi praktis ini (terima kasih kepada kolega saya yang lebih bijak) untuk mendapatkan dari string 36 panjang kembali ke array byte 16.
Untuk mengikuti kode dengan lebih baik, ambil contoh yang diberikan angka yang dipesan GUID di bawah ini. (Karakter ilegal digunakan untuk tujuan ilustrasi - setiap tempat karakter unik.) Fungsi akan mengubah urutan byte untuk mencapai urutan bit untuk pengelompokan indeks superior. Panduan yang diperintahkan ditampilkan di bawah contoh.
Tanda hubung dihapus: In MySQL, you can unhex a string using the To unhex a number in MySQL, use the The The syntax goes like this: CONV(N,from_base,to_base) Where ExampleHere’s an example to demonstrate: SELECT CONV('F',16,10); Result: +-----------------+ | CONV('F',16,10) | +-----------------+ | 15 | +-----------------+ In this case, we convert the number
Here’s another example using a larger number: SELECT CONV('FCA3B',16,10); Result: +---------------------+ | CONV('FCA3B',16,10) | +---------------------+ | 1034811 | +---------------------+ |