Developping for the translation industry RSS 2.0

 Wednesday, July 30, 2008

A common thing you may want to do when dealing with transactions involving various documents and files is insert them into you SQL Server database.  The following code snippet let you load a file from the disk and insert it into your database.

INSERT INTO myTable (documentData)
OPENROWSET(BULK N'c:\myDocument.doc', SINGLE_BLOB) as dt

Note that you need to name the select statement (here, I named it “dt”) or you will get this error message:

Server: Msg 491, Level 16, State 1, Line 3
A correlation name must be specified for the bulk rowset in the from clause.

Wednesday, July 30, 2008 12:38:15 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Code Snippet | SQL

About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2019
Stanislas Biron
Sign In
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2019, Stanislas Biron