开发者

How can I export images from SQL Server to a file on disk?

开发者 https://www.devze.com 2022-12-22 03:15 出处:网络
I have a User table that has all of their avatars saved in an image field.I\'d like to just ta开发者_运维问答ke that out of the database and store it as a regular file on disk.

I have a User table that has all of their avatars saved in an image field. I'd like to just ta开发者_运维问答ke that out of the database and store it as a regular file on disk.

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


Check this thread


http://msdn.microsoft.com/en-us/library/aa936933%28SQL.80%29.aspx

It says it is part of the devtools samples

0

精彩评论

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