SQL Server 2005 Image Data Type

Robin 66 Reputation points
2020-10-26T18:10:31.89+00:00

Hi,

We have an older version of Microsoft AX running on SQL Server 2005. I am trying to get the email address from the PRINTJOBSETTINGS column in SALESPRINTSETUP table. The PRINTJOBSETTINGS column is of Image data type. It does not contain images but information stored in such a way I don't know how to extract..

I ran the following query:

SELECT CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), PRINTJOBSETTINGS)) FROM SALESPRINTSETUP

And this is the results:

35056-imagedata.jpg

Can someone please tell me how to extract this information correctly? As you can see there is a space after every character which is making it more difficult to extract.

Thanks.

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,620 questions
{count} votes

2 answers

Sort by: Most helpful
  1. EchoLiu-MSFT 14,581 Reputation points
    2020-10-27T03:26:43.25+00:00

    Hi @Robin

    Please refer to:

        SELECT CONVERT(varbinary(max), CONVERT(varbinary(max), PRINTJOBSETTINGS)) FROM SALESPRINTSETUP  
    

    35242-image.png

    varchar(max)-------text
    nvarchar(max)-----ntext
    varbinary(max)----image

    For more details, please refer to:
    ntext, text, and image (Transact-SQL)

    If you have any question, please feel free to let me know.
    If the response is helpful, please click "Accept Answer" and upvote it.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Tom Phillips 17,731 Reputation points
    2020-10-27T20:50:57.54+00:00

    Just to be clear, the results you posted appears to be a "file" stored in an "image" data type, which is very common.

    That is not something you scan for email addresses. You would need to know the format of every file type stored in that field.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.