Solved

Extract email message from SQL iMAGE Column file

Posted on 2013-11-19
1
344 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

747 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

11 Experts available now in Live!

Get 1:1 Help Now