snippetsqlMinor
How to import a varbinary(max) column with bulk import?
Viewed 0 times
columnvarbinarywithbulkmaxhowimport
Problem
I have a varbinary(max) column that I need to bulk import. The data I'm putting into this column is a byte[] in C#. How do I format the data in the comma-delimited file used for bulk import? In other words, how do I convert from a byte[] to a string in a way the bcp utility will accept?
Solution
A varbinary value is of the form
So your CSV would be
Edit May 2013,
After testing, I can't get this to work with BULK INSERT with or without a format file.
I will post something more when I get it working. I can't delete this answer
0x01020304 for SQL Server to read.So your CSV would be
col1,col2,varbinary
foo,1,0x01020304
bar,2,0x988776655443Edit May 2013,
After testing, I can't get this to work with BULK INSERT with or without a format file.
I will post something more when I get it working. I can't delete this answer
Code Snippets
col1,col2,varbinary
foo,1,0x01020304
bar,2,0x988776655443Context
StackExchange Database Administrators Q#3138, answer score: 5
Revisions (0)
No revisions yet.