Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:54:08+00:00 2026-06-03T16:54:08+00:00

I have some columns with image data type and I want to preview (or

  • 0

I have some columns with image data type and I want to preview (or browse) the data in those tables. When I use Select top 1000 rows in SQL Server Management Studio, the value of image columns is displayed in hexadecimal. What’s the easiest way to preview those images since the hex-value is not useful to me?

PS.: database is not under my control, so changing data type is not an option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:54:09+00:00Added an answer on June 3, 2026 at 4:54 pm

    I would write a proc (or query; see below) to export the binary out to the file system and then use any old off the shelf photo management utility (i.e. Windows Photo Viewer) to take a look at what’s inside.

    If your clever in your file naming you could give yourself enough information about each image in the name to quickly find it in the database again once you’ve visually located what your looking for.

    Here is a proc that will export binary to the file system. I modified from this sample code. It’s untested but should be extremely close for concept. It’s using BCP to export your binary. Check here for the full docs on the BCP utility.

    The proc also gives you the ability to export everything in the table, or only a single row based on a the passed primarykey. It uses a cursor (yuck), as well as some dynamic sql (yuck, yuck) but sometimes you gotta do what you gotta do.

     CREATE PROCEDURE ExportMyImageFiles
     (   
       @PriKey INT,
       @OutputFilePath VARCHAR(500)
     ) 
     AS 
     BEGIN 
         DECLARE @sql VARCHAR(8000) 
    
         IF @PriKey IS NULL /* export all images */
         BEGIN
            DECLARE curExportBinaryImgs CURSOR FAST_FORWARD FOR
    
            SELECT 'BCP "SELECT MyImage FROM [dbo].[MyTable] 
               WHERE PrimaryKey =' + CAST(PrimaryKey AS VARCHAR(25)) + 
               '" queryout ' + @OutputFilePath + MyImageName + '.' + 
               MyImageType + ' -S MyServer\MyInstance -T -fC:\Documents.fmt'
            FROM [dbo].[MyTable]
    
            OPEN curExportBinaryImgs
            FETCH NEXT FROM curExportBinaryImgs INTO @sql
    
            WHILE @@FETCH_STATUS = 0
            BEGIN            
                EXEC xp_cmdshell @sql, NO_OUTPUT
                FETCH NEXT FROM curExportBinaryImgs INTO @sql
            END
    
            CLOSE curExportBinaryImgs
            DEALLOCATE curExportBinaryImgs
         END
         ELSE       /* Export only the primary key provided */     
         BEGIN
            SELECT @sql = 'BCP "SELECT MyImage FROM [dbo].[MyTable] 
            WHERE PrimaryKey =' + CAST(PrimaryKey AS VARCHAR(25)) + 
                '" queryout ' + @OutputFilePath
                + MyImageName + '.' + MyImageType + 
                ' -S MyServer\MyInstance -T -fC:\Documents.fmt'
            FROM [dbo].[MyTable]
            WHERE PrimaryKey = @PriKey
    
            EXEC xp_cmdshell @sql,NO_OUTPUT
         END 
     END
    

    This is all assuming of course that what is stored in your Image column is actually an image and not some other file type. Hopefully if it is an image you also know the type, bmp, jpg, png, gif, etc.

    If you don’t want the hassle or reusability of a full blown proc try single query like this:


        DECLARE @OutputFilePath VarChar(500) = /* put output dir here */
    
        DECLARE @sql VARCHAR(8000)
        DECLARE curExportBinaryImgs CURSOR FAST_FORWARD FOR
        SELECT 'BCP "SELECT MyImage FROM [dbo].[MyTable] 
           WHERE PrimaryKey =' + CAST(PrimaryKey AS VARCHAR(25)) + 
           '" queryout ' + @OutputFilePath + MyImageName + '.' + 
           MyImageType + ' -S MyServer\MyInstance -T -fC:\Documents.fmt'
        FROM [dbo].[MyTable]
    
        OPEN curExportBinaryImgs
        FETCH NEXT FROM curExportBinaryImgs INTO @sql
    
        WHILE @@FETCH_STATUS = 0
        BEGIN            
            EXEC xp_cmdshell @sql, NO_OUTPUT
            FETCH NEXT FROM curExportBinaryImgs INTO @sql
        END
    
        CLOSE curExportBinaryImgs
        DEALLOCATE curExportBinaryImgs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have some data in a sybase image type column that I want to use
I have 2 tables with some columns and another table that I want its
We have some columns with data that must always be in uppercase to ensure
I have some data I am querying. The table is composed of two columns
I have a web-site that generates some simple tabular data as html tables, many
I have some 6 columns in Silverlight 4 Datagrid. On each cell in the
In my implementation of JTable . I have to keep some columns editable and
I've got some Columns in a DataGridView that have their Binding property set to
i have one database, and it contains some columns. My requirement is that how
I have written some JS and CSS that allows certain columns to be flexible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.