Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing files in MS SQL using PHP?

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
Does anyone know the most effective way of storing files in an MS SQL database? I typically use MySQL and use the BLOB field. Is this the correct method in MS SQL as well?
 
Image type (SQL2000), image or varbinary(MAX) (SQL2005).

Method itself is correct, though CLOB/BLOB support in MSSQL2k is kind of clumsy - and there are endless discussions about whether keeping binaries in a relational database is worth a trouble or not.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
So it's possible to use the image datatype in MS SQL to store binary data, but is that only good for images? Would it work for PDF or XLS files? If so, do you need to store the MIME type in a separate field?
 
> So it's possible to use the image datatype in MS SQL to store binary data, but is that only good for images?

"image" is kind of misleading - that data type accepts binary data of any kind.

> If so, do you need to store the MIME type in a separate field?

Yes, and size and original filename all other metadata.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top