how to use bcp.exe to insert pdf file into varbinary(max) field in sql server 2005

Discussion in 'Databases' started by smh, Jul 25, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. smh

    smh

    I am told I cannot use bulkcopy sql query to insert a pdf or doc file into a varbinary(max) field I have, but that I have to use bcp.exe.

    I have never used this utility before and looked but could find no examples on how to use bcp insert such pdf, etc filesusing bcp.

    Does anyone know the command to do this using bcp.exe?

    Any help, as always, will be greatly appreciated.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Are you trying to insert into our server using bcp? We do not allow users to bulk copy using bcp.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    As stated in the previous post, we do not allow bcp because of potential security issue.

    Do you have a local SQL server? If you do, you can use bcp to import the data into your local database, back up your database, and use the restore tool in the control panel to restore your DB.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. smh

    smh

    Yes, it turns out bcp is the only method (other than changing the table locally and then importing it into the server database).

    However, I did not see any samples of inserting a pdf or word.doc file into a varbinary(max) field. Further more, I am not sure what the process is since I am told that I use the bcp.exe command from the local machine's command prompt. How is it uploaded to the server?

    I have never had to use Bcp before so any ideas greatly appreciated.

    SM Haig
     
  5. smh

    smh

    The problem is that users are storing reports in a table in the database. These are pdf or doc files. I need to provide an easy mechanism for them to do this each month. I have a stored procedure that will do this fine locally, but since this does not work with a web server, I am not sure what I can do to make this an easy process.

    I was under the impression that I could not use the stored procedure but had to use bcp which I am unfamiliar with. But from this post, you seem to be saying that there is no way to insert a pdf file that is on a local drive into a table in a database on the webserver because of security.

    So, using bcp is just another way toinsert a pdf into a record on the local server. But I have a stored procedure I have been using locally. What I needed was a method to insert this file into the web server which I guess is not possible

    So it seems that the only way to do this is to pass the database back and forth from the web server to the local server using backup and restore which does not seem like a good idea; or to insert the file into a local work table which will just hold the report and any other info needed, then import that table into the web database, use the stored procedure to put that report or reports in the work table into the proper table and then delete this imported work table.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page