Developping for the translation industry RSS 2.0



 Wednesday, 30 July 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)
SELECT * FROM
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, 30 July 2008 12:38:15 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Code Snippet | SQL

Navigation
Advertisement
About the author/Disclaimer

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

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