Using image files in SQL

  • I am new to SQL but as the sole IT guy in a busy school I get to do everything. I have moved tables from an in house academic database in access to SQL. I want to create a new table in SQL containing jpeg pictures of students, but I cannot do this in Enterprise Manager. Is there an easy way - I have looked through forum scripts but no joy.

    A pointer in the right direction would be gratefully recieved

  • To import image data you can you the textcopy utility. You need to populate the table with rows and then run textcopy for each jpeg you want to import

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

  • You can also do it in code using the ADO stream object, or use the BII utility (I think from the resource kit).

    Andy

    http://qa.sqlservercentral.com/columnists/awarren/

  • Textcopy is fully explained in BOL

    this is from a batch file I have that is used to insert our default document template

    textcopy /S%1 /D%2 /U%3 /P%4 /TdocumentTemplate /Cdocument /W"WHERE master = 1" /FMotherDot.dot /I %5

    so MotherDot.dot is the word template to be loaded and "documentTemplate" is the table, "document" is column and "WHERE master=1" is the where clause that indicates which row to insert it into.

    I hope that helps

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

  • Worked OK for me so far, using this batch file

    textcopy /Sserv1 /D "[cowden limited]" /Umwd /Psmeg /Tpl /Cbody_word /W"WHERE plkey = 'B0001' " /Franges.doc /II

    ...where body_word is an image file.

    But if a change the last I to an O to output the Word doc to a file, I get

    "ERROR: Problem with file 'ranges.doc' ."

    This happens whether or not the file already exists.

  • Steve,

    I found this MS example of using the ADO stream with VB. Support.microsoft.com

    Microsoft Knowledge Base Article - Q258038

    HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply