这是我程序返回@v_buffer
变量的一部分。 问题是,我想要上传的文件大小大于8000字节。这就是为什么我需要使用varbinary(max)
类型。 但sp_oamethod读取返回给我一个错误。 有人知道使用sp_oamethod解决我的问题很热吗?通过sp_oageterrorinfo
返回Sp_oamethod上传大小大于8000的文件
declare @returnCode int
declare @v_file int
declare @v_buffer varbinary(max)
declare @v_fullpath nvarchar(400) --pdf file phusical location
exec @returncode = sp_oacreate 'adodb.stream', @v_file out
exec @returncode = sp_oamethod @v_file, 'open'
exec @returncode = sp_oasetproperty @v_file, 'type', 1
exec @returncode = sp_oasetproperty @v_file, 'loadfromfile', @v_fullpath
exec @returnCode = sp_oamethod @v_file, 'read', @v_buffer out, -1
if @returncode <> 0
begin
exec sp_oageterrorinfo @v_file
end
exec @returnCode = sp_OAMethod @v_file, 'Close'
exec @returnCode = sp_OADestroy @v_file
错误消息:
0x8004271A,ODSOLE扩展过程,在srv_convert错误。
坦克的建议,但我不想使用任何其他工具比SQL Server。 我发现一个文件分割方法的解决方案,也适用于我的情况。 – Mat
@Mat很好。需要说明的是,SQLCLR与'sp_OA *'存储过程一样多的SQL Server。您不需要[销售]我销售的[SQL#](http://SQLsharp.com/)产品,因为此特定功能很容易完成;它只有几行代码。程序集加载到数据库中,以便随数据一起备份(与扩展存储过程不同)。另外,SQLCLR比OLE Automation procs更高效更安全。他们可以使用新的数据类型,并且可以很容易地返回一个'VARBINARY(MAX)'。然后你可以这样做:'UPDATE tbl SET tbl.FileData = dbo.GetFile(tbl.path);'。 –