Groups | Blog | Home
all groups > sql server (microsoft) > may 2007 >

sql server (microsoft) : storing docs in a database - how to upload?


M NO[at]SPAM
5/25/2007 10:33:32 AM
I have a directory of files that I would like to upload with some data
to a table so that I can store the files in the db. I'm not trying to
parse files into rows, I want to stick the actual file in the column.
Is there some kind of insert script, or bulk copy that I can use?

I have about 150 docs and I would rather not go through the whole app,
pick the file, upload it. etc.

thx,
M@
Jens
5/27/2007 10:02:41 AM
No, there is no SQL command to do this, you will have to use a client
code script for doing this like the following one in C#:

FileStream fs = new FileStream(filePath, FileMode.Open,
FileAccess.Read);
BinaryReader br = new BinaryReader(fs);

byte[] photo = br.ReadBytes((int)fs.Length);

//Clean the house
br.Close();
fs.Close();

Jens K. Suessmeyer.

---
http://www.sqlserver2005.de
---
AddThis Social Bookmark Button