SQL Server 2000:如何从存储过程将图像变量保存到文件系统中的文件
我有一个接收 @Data
image
参数的存储过程。
我想将它从存储过程保存到文件系统。
知道怎么做吗?
I have a stored procedure that receives a @Data
image
parameter.
And I want to save it to the file system from a stored procedure.
Any idea how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您可以使用 OLE 自动化 (ADODB.Stream) 从 SQL Server 2000 存储过程写入二进制数据,如 这里和这里。下面的示例使用 varbinary 变量,但它应该与您的图像参数类似地工作。
请注意,通过此方法(以及我所知道的 SQL2000 中的所有其他方法)对文件系统的访问将发生在 SQL Server 进程的安全上下文中,而不是存储过程的调用者。
如果您不习惯将 ADO 组件加载到 SQL Server 进程中,您可以考虑实现 扩展存储过程来写入您的文件。
You can use OLE automation (ADODB.Stream) to write binary data from a SQL Server 2000 stored procedure, as described here and here. The sample below uses a varbinary variable, but it should work similarly with your image parameter.
Note that access to the file system via this method (and all others in SQL2000 that I know) will occur under the security context of the SQL Server process, not the caller of the stored procedure.
If you aren't comfortable loading the ADO components into your SQL Server process, you could look into implementing an extended stored procedure to write your files.