SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Writing an image to a database via stored proc only which reads a physical location.

Last post 08-28-2008, 9:07 by CalmYourself. 1 replies.
Sort Posts: Previous Next
  •  08-28-2008, 8:37 14398

    Writing an image to a database via stored proc only which reads a physical location.

    Hi,

     I would like to pass a filename to a proc and let the proc handle image storage and from a physical location. Please advise?

     

    Thanks,

    JK.

  •  08-28-2008, 9:07 14399 in reply to 14398

    Re: Writing an image to a database via stored proc only which reads a physical location.

    Something like so should work:

    CREATE PROCEDURE ImportFile
          @Filename NVARCHAR(512)
    AS
          DECLARE @Sql NVARCHAR(512)
          SET @Sql = 'INSERT INTO bindata(data)
                      SELECT
                            *
                      FROM
                            OPENROWSET(BULK ''' + @Filename + ''', SINGLE_BLOB)'

          EXEC (@sql)
     


    Why go against tradition when we can admit defeat, live in decline, be the victim of our own design?
    http://dotnet.org.za/calmyourself
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems