Link to home
Start Free TrialLog in
Avatar of Shezad Ahmed
Shezad AhmedFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Extract email message from SQL iMAGE Column file

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
ASKER CERTIFIED SOLUTION
Avatar of EugeneZ
EugeneZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial