這是我程序返回@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);'。 –