Monthly Archives: October 2020

Using the column name in your file naming convention in Access OLE Export / SQL Blob Export

When you export images and files using Access OLE Export / SQL Blob Export and each row of your table or result set contains multiple columns that contain the blob data e.g.

you could previously only use the column index in the file naming convention to identify the source column of the exported file e.g.

which would then name the exported files this way:

Files with the suffix 0002 indicates that it was exported from the 2nd column (ThumbnailPhoto), and 0003 from the 3rd column (LargePhoto).

From version 3.17 onwards, you can now use the column name in the naming convention, using the <%columnname%> tag e.g.

The exported files are then named this way:

which is more meaningful.

 

Using the column name in your file naming convention in SQL Image Viewer

In SQL Image Viewer 10.2, we’ve added a new option to the system values for your file naming convention.

Using this example:

Each row contains 2 binary-type columns.  We can name our exported images using the ProductPhotoID column, but to identify the source column for the images, we could previously only use the column index

resulting in file names like these:

The first part of the file name is the ProductPhotoID value, formatted to 4 digits, and the second part is the column index (columns 2 and 3).

From SQL Image Viewer 10.2 onwards, you can now use the column name as part of the naming convention.

which is used to name the exported files

You can select this new option (columnname) in the File Naming Convention page.

If you want to use a different value for the column name, simply use the alias syntax applicable to your database engine.  For SQL Server, this would be using the AS option e.g.

How to view image data type in SQL Server

The image data type in SQL Server is frequently used to store variable length binary data.  It does not have to store only ‘images’, though most people associate that data type with images.

You may occasionally need to view the type of data that’s stored, but SQL Server Management Studio can only display the binary representation of the data (we’re using the AdventureWorks sample database here).

SQL Image Viewer is one tool that can display the image directly in the result set.

Interesting points to note:

  • the image format was never provided.  SQL Image Viewer can read the binary data and determine the image format itself.  It recognizes png, gif, jpg, tiff, bmp, wmf, emf, dicom, and raw camera formats.
  • details of the image like size and resolution are provided automatically

Though its name might suggest otherwise, SQL Image Viewer doesn’t just support ‘images’.  It recognizes a wide variety of file formats, including Microsoft Office documents, OpenOffice documents, PDF, epub, multimedia files (avi, wav, mp3, mp4, svg, swf, flv, mkv, webm, m4v, mov, 3gp), and compressed archives (zip, 7zip, rar, bzip2, gzip).

For PDFs, SQL Image Viewer is able to display a thumbnail of the first page, and also the number of pages in the file.

Once retrieved, you can export the binary data.  You can export them to a spreadsheet:

or simply export them as individual files:

You can name the files using values from other columns.  You can also convert the exported images to other formats:

For images that contain EXIF values, you can view these values using the internal viewer:

SQL Image Viewer supports Oracle, PostgreSQL, MySQL, MariaDB, Microsoft Access, SQLite and ODBC supported databases.

Thus, you can easily view the data that’s stored in

  • binary and varbinary columns in Oracle databases
  • bytea columns in PostgreSQL databases
  • binary and varbinary columns in MySQL and MariaDB databases
  • binary and varbinary columns in Microsoft Access databases
  • OLE-Object columns in Microsoft Access databases

Download a free 14-day trial now and see how SQL Image Viewer can make working with image data types in SQL Server so much easier.

Using the newer Excel format (xlsx) in your exports

When SQL Image Viewer first supported exporting your result sets to Excel spreadsheets, it only supported the older .xls format.

Since version 9.7 (released in December 2019), the newer Excel format (.xlsx) is now supported.  However, because SQL Image Viewer uses your last export settings when you choose the Excel file name, you may still be using the older .xls format.

To export your data and images to the new Excel format, simply change the file extension from xls to xlsx.

For new users, and users who have never exported to Excel previously, the default extension used is xlsx,  so no action is required on your part to use the new Excel format.

The main advantage in using the xlsx format is that the maximum number of rows in your worksheet increases to 1,048,576 from 65,536 rows.