Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: save an image into a table using Query Analyzer

    I have a table with two fields Part_num and Pic in SQL server 2000
    Pic is of Image type. Is there a way I can save images for each part_num using Query analyzer?

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    You can use BULK INSERT or bcp.

    From BOL:



    xp_cmdshell 'bcp pubs..bitmap in test.doc -Usa -Ppassword -Sservername'

    -------------------------------------------------------------------
    The Bcp.fmt file:

    8.0
    1
    1 SQLIMAGE 0 5578 "" 1 c1

    Using the BULK INSERT statement to bulk copy the Test.doc data file into the bitmap table in the pubs database, execute from a query tool, such as SQL Query Analyzer:

    BULK INSERT pubs..bitmap FROM 'c:\test.doc'
    WITH (
    FORMATFILE = 'c:\Bcp.fmt'
    )

  3. #3
    Join Date
    Oct 2003
    Posts
    3
    Sorry I'm new to this, Will this work if I have an image, lets say 150.bmp on C: drive? So would it be
    BULK INSERT pubs..bitmap FROM 'c:\150.bmp'
    WITH (
    FORMATFILE = 'c:\150.bmp'
    ) ?

    Originally posted by snail
    You can use BULK INSERT or bcp.

    From BOL:



    xp_cmdshell 'bcp pubs..bitmap in test.doc -Usa -Ppassword -Sservername'

    -------------------------------------------------------------------
    The Bcp.fmt file:

    8.0
    1
    1 SQLIMAGE 0 5578 "" 1 c1

    Using the BULK INSERT statement to bulk copy the Test.doc data file into the bitmap table in the pubs database, execute from a query tool, such as SQL Query Analyzer:

    BULK INSERT pubs..bitmap FROM 'c:\test.doc'
    WITH (
    FORMATFILE = 'c:\Bcp.fmt'
    )

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Check this (I tested it):

    BULK INSERT pictures FROM 'c:\tmp\bridge.jpg'
    WITH (
    FORMATFILE = 'c:\tmp\bcp.fmt'
    )

    bcp.fmt
    3935 - size of image, you have to change collation if it needs.

    See attachment.
    Attached Files Attached Files
    Last edited by snail; 10-02-03 at 23:44.

  5. #5
    Join Date
    Oct 2012
    Posts
    2
    BULK INSERT pictures FROM 'c:\tmp\bridge.jpg'
    WITH (
    FORMATFILE = 'c:\tmp\bcp.fmt'
    )

    How can i retrieve above picture from SQL using query analyzer command?
    Last edited by parsdc; 10-17-12 at 10:09.

  6. #6
    Join Date
    Oct 2012
    Posts
    2

    extracted

    BULK INSERT pictures FROM 'c:\tmp\bridge.jpg'
    WITH (
    FORMATFILE = 'c:\tmp\bcp.fmt'
    )

    How can i retrieve above picture from SQL using query analyzer command?
    Last edited by parsdc; 10-17-12 at 10:10.

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Query Analyzer doesn't handle JPG files, it has no User Interface components for dealing with picture data.

    You would have to retrive the picture data into a web page or an application that could deal with pciture data and then display the data on the client.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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