I am taking a backup of my dataset as a csv.
However, one of the table contains a binary field. I came across this function, sys.fn_sqlvarbasetostr, provided by MS SQL but I cant find which character encoding this will use.
If you know any other approach to do this, plz let me know.
Edit:-
We ended up doing this in c#, but I am still marking Alex’s answer as correct because if I was to do this through SQL queries then his answer will work.
Approach we ended up with:-
For binary column csv contains a hex value, so an example row looks like ‘somename’,’someothertext’, 2bcd8 (hex representing binary data).
Initially we were not writing hex data properly. 0x3d455 failed, ‘0xa2342’ failed, ‘3444d’ failed, 2bcd8 SUCCESS!
In 2008 you can convert to a string directly;
SQL2k:
For