本文介绍了如何保存(全部)SQL服务器映像数据类型文件系统使用正确的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表中不同类型的文件(TXT,DOC,JPG等),我想他们都保存到我的文件系统。我知道如何做到这一点按文件文件,但它是没有用的,我要做一个循环,同时节省了右扩展的所有文件。有什么建议?

I have different types of files in table (txt, doc, jpg, etc) and I want to save them all to my file system. I know how to do it file by file, but it's no use, I have to do a loop that saves all files with right extensions at once. Any advice?

我现在做这种方式:

DECLARE @ObjectToken INT
EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
EXEC sp_OASetProperty @ObjectToken, 'Type', 1
EXEC sp_OAMethod @ObjectToken, 'Open'
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, <this is where binary data goes>
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, 'd:/file.txt', 2
EXEC sp_OAMethod @ObjectToken, 'Close'
EXEC sp_OADestroy @ObjectToken

所以,我的问题是有没有办法来对数据库表中的所有记录(保存所有文件),同时并用设置正确的文件扩展名的每个保存的文件这样做呢?

So, my question would be is there a way to do this for all records (save all files) in db table at once and with setting the correct file extension for every saved file?

推荐答案

我解决了这个问题。当我发现这实在是不容易从SQL Server 2000数据库迁移至2005年,只有解决方案,它的工作原理是这样的 - 的

I resolved the problem. As I found it is REALLY not easy to migrate db from SQL Server 2000 to 2005. Only solution which works is this one - http://tek-works.com/fixing-there-is-already-an-object-named-sysnsobjs-in-the-database/

完成这些步骤后,你只需要设置兼容级别为90(右键单击数据库>属性>兼容性级)

After completing those steps you just have to set Compatibility level to 90. (Right click on database > Properties > Compatibility level)

然后你可以使用VARBINARY(MAX),并保存完整的图像数据类型的二进制文件的文件系统。

Then you can use VARBINARY(MAX) and save complete image datatype binary files to filesystem.

祝迁移!

这篇关于如何保存(全部)SQL服务器映像数据类型文件系统使用正确的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 00:17