开发者

How do I retrieve and image datatype from SQLServer 2005 without programmatic access from some other language

I have a SQL Server 2005 table with an image datatype as 开发者_开发百科on of the table fields. I have a specific row I am interested. I'd like to write the binary data in the image field to a file on a network share.

Let's call the share \server\sharename


This worked for me. Obviously path names and instance names may need to be altered your end.

It requires master..xp_cmdshell enabled (but you could just run bcp directly if there is no need to do it in T-SQL)

EXEC master..xp_cmdshell 
'bcp "SELECT [LargePhoto] FROM [AdventureWorks2008].[Production].[ProductPhoto] WHERE [ProductPhotoID]=70" queryout C:\temp\YourImage.jpg -S(local)\SQL2008 -T -fC:\temp\test.fmt'

It requires the following format file C:\temp\test.fmt

9.0
1
1 SQLBINARY 0 0 "" 1 col1 "" 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜