Solved

Extract email message from SQL iMAGE Column file

Posted on 2013-11-19
1
346 Views
Last Modified: 2013-11-21
HI

I have uploaded an outlook email message to SQL using:

Column type is 'image'.

UPDATE dbo.AMGR_Letters_Tbl
SET    TextCol = (SELECT *
                FROM   OPENROWSET(BULK 'C:\test\test.msg',
                       SINGLE_BLOB) AS x)
 WHERE Sequence_Number = 182

Now I want to extract the same file as an outlook email message.

Code I used:

DECLARE  @Command NVARCHAR(4000)
 

SET @Command = 'bcp "SELECT TextCol FROM EsconaTutorial.dbo.AMGR_Letters_Tbl WHERE Sequence_Number = 182" queryout "C:\Test\TEXT.msg" -T -n -S127.0.0.1'
 
PRINT @Command -- debugging
 
EXEC xp_cmdshell   @Command
GO

I am unable to open the extracted file .

I get "The file may not exist, you may not have permission to open it.

Thanks,
Shezad
0
Comment
Question by:Shezad Ahmed
1 Comment
 
LVL 42

Accepted Solution

by:
EugeneZ earned 500 total points
ID: 39664588
try to use sql format file
see this step=by-step  example how to export image datatype from sql by using bcp
http://ayesamson.com/2012/06/06/exporting-photos-with-bcp/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now