如何将映像从SQL Server导出到磁盘上的文件? [英] How can I export images from SQL Server to a file on disk?
本文介绍了如何将映像从SQL Server导出到磁盘上的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用户表,其所有的头像都保存在图像字段中。我想把它从数据库中拿出来,并将其作为一个常规的文件存储在磁盘上。
I have a User table that has all of their avatars saved in an image field. I'd like to just take that out of the database and store it as a regular file on disk.
我环顾四周,看到一些代码为textcopy,但是由于某种原因似乎在我的机器上这是我写的代码。任何人都知道这样做的方法?
I looked around and saw some code for textcopy, but that doesn't seem to be on my machine for some reason. Here is the code I wrote up anyway. Anyone know a way to get this done?
DECLARE @exec_str varchar (255)
SELECT @exec_str =
'textcopy /S (local)\SQLEXPRESS' +
--' /U ' + @login +
--' /P ' + @password +
' /D thedatabase' +
' /T User'+
' /C AvatarImage' +
' /F "d:\Avatars\' + User.Name + '.jpg"' +
' /O'
FROM [User]
WHERE UserID = 2
EXEC master..xp_cmdshell @exec_str
推荐答案
检查这个线程
这篇关于如何将映像从SQL Server导出到磁盘上的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文