Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:26:02+00:00 2026-05-25T12:26:02+00:00

I am taking a backup of my dataset as a csv. However, one of

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:26:03+00:00Added an answer on May 25, 2026 at 12:26 pm

    In 2008 you can convert to a string directly;

    declare @b varbinary(1024) = 0xDEADBEEFF00D
    select convert(varchar(1024), @b, 1) + ','
    
    >>0xDEADBEEFF00D,
    

    SQL2k:

    declare @base   binary(6)   set @base = 0xB00BB00BB00B
    declare @aschar varchar(14) set @aschar = dbo.fn_sqlvarbasetostr(@base)
    
    select 'as string: ' + @aschar
    
    --convert back to binary
    declare @bin binary(6)
    declare @sql nvarchar(512) = 'set @bin=convert(binary(6),' + @aschar + ')'
    execute sp_executesql @sql, N'@bin binary(6) output', @bin=@bin output
    
    select 'as binary:', @bin, case when @bin = @base then 'ok' end
    

    For

    >>as string: 0xb00bb00bb00b
    >>as binary: 0xB00BB00BB00B  ok
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
Taking a JavaScript object with 4 properties: function Object() { this.prop1; this.prop2; this.prop3; this.prop4;
While taking backup mysqldump I use this command and getting 'too many connection error'
We are taking db backups programatically by using SqlServer.Management.Smo.Backup class. It is working perfectly.
Taking this file as an example, I'm trying to read the data in a
Taking in consideration a table tbl_users , I want to get a list of
While taking backup of a schema, will it also copies the permissions granted on
Woke up this morning with a page that our cluster was down. It came
I am currently taking database backup manually using phpmyadmin export as a sql dump,the
how do i restrict taking an application data backup using itunes sync.. its a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.