Results 1 to 5 of 5

Thread: Save Image to Database TSQL issue

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2018
    Posts
    56

    Thumbs up Save Image to Database TSQL issue

    Please i need help with this line, been giving headache for hours.

    Code:
    insert into tblPicture1 (AcctNo, MCard,FileName)  SELECT '900901', * FROM Openrowset( Bulk 'C:\MyFiles\Media\Photo14061004777.JPG', Single_Blob) as img,'ChurchPhoto'
    Error i get is Incorrect syntax near 'ChurchPhoto'

    Please help.

    The table tblPicture1 has the following structure:
    [AcctNo] [nvarchar](50) NULL,
    [MCard] [image] NULL,
    [FileName] [nvarchar](50) NULL

    Thanks.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,444

    Re: Save Image to Database TSQL issue

    Not having worked with TSQL, my Bet would be
    Code:
    insert into tblPicture1 (AcctNo, MCard,FileName) 
    SELECT '900901', img.*,'ChurchPhoto' FROM Openrowset( Bulk 'C:\MyFiles\Media\Photo14061004777.JPG', Single_Blob) as img
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2018
    Posts
    56

    Re: Save Image to Database TSQL issue

    Quote Originally Posted by Zvoni View Post
    Not having worked with TSQL, my Bet would be
    Code:
    insert into tblPicture1 (AcctNo, MCard,FileName) 
    SELECT '900901', img.*,'ChurchPhoto' FROM Openrowset( Bulk 'C:\MyFiles\Media\Photo14061004777.JPG', Single_Blob) as img
    Thank you so much

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,169

    Re: Save Image to Database TSQL issue

    Btw, the name of the single column in OPENROWSET resultset is "BulkColumn" if you want to be explicit instead of using img.*

    cheers,
    </wqw>

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,444

    Re: Save Image to Database TSQL issue

    Quote Originally Posted by wqweto View Post
    Btw, the name of the single column in OPENROWSET resultset is "BulkColumn" if you want to be explicit instead of using img.*

    cheers,
    </wqw>

    Cheers wqweto.
    Since i've never worked with MS-SQL-Server (and thusly with TSQL), i didn't know that, so my "img.* " was kinda of "be on the safe side" (as safe as it can be)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width