Saturday, July 31, 2010
Home Retrieving XML Writing XML General Contact About  

How To: Inserting Binary Data using XML (15123 Requests)

Answer provided by Joshua Allen.

The Base 64 algorithm used by SQL Server 2000 is the same one specified in RFC 1521. Below is some sample code that you can use to do base64 encoding/decoding according to the RFC.

However, the best method for inserting base64 encoded data is to use a schema and specify the data type as bin.base64. You can then use this schema with an updategram or with BulkLoading and the data will be automatically decoded into the binary field in the database.

Of course, you could always write your own routines to manipulate the blob fields directly in the database, but I think it is much easier to just post an updategram.

C++ Sample Code:
Base64Coder.cpp
Base64Coder.h
code.cpp

Feedback

# Convert Binary to XML Tom Grisafe

Now how would you go the other direction, Binary Data back into XML in SQL Server.

# re: How To: Inserting Binary Data using XML jim

other examples of this approach? c#, vb, etc?

# re: How To: Inserting Binary Data using XML dominic grisafe

hi uncle tom its dominic i looked up your name on google and read those letters you wrote about the catholic church. just saying hi.
love,
dominic

# re: How To: Inserting Binary Data using XML tim

Ok, thanks! But...

1) How do we write a stored procedure that accepts an XML fragment containing base-64 encoded data, and automagically converts that b64 string to binary for updating an image column?

2) And what would that XML document look like exactly? You say we need a schema...so how would I craft an XML fragment to pass into this procedure?

For example, let's say I want to insert something like:
<employees>
<employee>
<id>5</id>
<photoAsBase64>AQAAE83392D23=//</photoAsBase64>
</employee>
...etc...
</employees>

Thank you

# how to parse binary data from xml selva

how to parse binary data from the xml
loading mxl file and retrive binary data and save as exe file in vc++
sample code in vc++

# re: How To: Inserting Binary Data using XML jgtjtg dad

tjytrjyrjkryk

# re: How To: Inserting Binary Data using XML jgtjtg dad

tjytrjyrjkryk iryiyi iiyt itri

# qvys fdsakleow nqmcbop@mail.com

imejn blter fdak cidonsjav zeodn sdfn xvkjscp

# qvys fdsakleow nqmcbop@mail.com

imejn blter fdak cidonsjav zeodn sdfn xvkjscp

# re: How To: Inserting Binary Data using XML asdf

wtfh

# re: How To: Inserting Binary Data using XML asdf

wtfh

# re: How To: Inserting Binary Data using XML fgd

fdsgf

# How to: Convert image datatype (from SQLServer 2000) to base64 Aymeé

Please, How can i may convert image datatype (from SQLServer 2000) to base64. I need this for import photos stored in a sqlserver database to a LDAP directory that has Gosa as its fronted. Thank you so much.

Title  
Name  
Url
Comments   


FAQ #51

last updated:
10/5/2001


Did the information in this faq help answer your question?





 
 

Survey Results: 43
Yes No N/A

© 2001, 2002, 2003 sqlxml.org