0

I am trying to extract blob data from a SQL SERVER 2008 R2 database. The data is annotation data that an application stores. I have done some research and I have been partially successful in converting the data. I get about 20-30 first characters of each entry. This is the SQL statement I used:

select CONVERT(varchar(MAX), CONVERT(varbinary, blob)) from annotation_data;

How can I get all the data?

Randi Vertongen
16.6k4 gold badges36 silver badges64 bronze badges
asked Jun 13, 2019 at 3:25
1
  • 1
    What data type is blob? If it is a varbinary already then you really don't need to cast it to varbinary before you cast it to varchar.. Commented Jun 13, 2019 at 6:17

1 Answer 1

5

The value truncates because you have not specified a length for the convert to varbinary. Without a specific length you get the default which is 30.

select convert(varchar(max), convert(varbinary, '1234567890123456789012345678901234567890'));
select convert(varchar(max), convert(varbinary(max), '1234567890123456789012345678901234567890'));

Result:

123456789012345678901234567890
1234567890123456789012345678901234567890
answered Jun 13, 2019 at 6:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.