Solved

Extract email message from SQL iMAGE Column file

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL: Get Holding Day Based On Transfer Date And Return Date 13 74
SQL Backup Question 2 30
SQL R 21 28
MS SQL + date 6 20
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

828 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