Sql server 克服sql server存储过程参数的8k限制

Sql server 克服sql server存储过程参数的8k限制,sql-server,Sql Server,我最近解决了VB6应用程序在使用ADO 2.8和Recordset.Field的AppendChunck方法将大型二进制对象保存到sql server时遇到的一个问题。如果数据太大,我将在for循环中得到“无效句柄”或“没有足够的系统存储来执行此操作”。我通过向存储过程发送块并使用“updatetext”修复了这个问题。但是,由于8k限制,我现在一次只能发送8k个字符。有人知道一个好的解决方法吗?下面是我的狂欢 @chunck binary(8000), @result_id int as

我最近解决了VB6应用程序在使用ADO 2.8和Recordset.Field的AppendChunck方法将大型二进制对象保存到sql server时遇到的一个问题。如果数据太大,我将在for循环中得到“无效句柄”或“没有足够的系统存储来执行此操作”。我通过向存储过程发送块并使用“updatetext”修复了这个问题。但是,由于8k限制,我现在一次只能发送8k个字符。有人知道一个好的解决方法吗?下面是我的狂欢

@chunck binary(8000),  
@result_id int

as

declare @pointer binary(16),  
        @imagelength int,  
        @datalength int  


--get the pointer and length to the image column    
select @pointer = textptr(result_image),  
       @imagelength = datalength(result_image)  
from dbo.dash_result  
where result_id = @result_id

if @pointer is null

update dbo.dash_result  
set result_image = @chunck  
where result_id = @result_id  

else

begin

  --append the chunck of data to the end  
  set @datalength = datalength(@chunck)  
  updatetext dbo.dash_result.result_image @pointer @imagelength 0 @chunck

end

如果您使用的是SQL Server 2005,则可以使用varbinary(MAX)数据类型或varchar(MAX)数据类型,具体取决于存储的数据类型。我相信这些可以容纳多达2千兆的数据。

对于sql server 2000,将参数声明为文本。请注意,它必须是一个参数而不是局部变量,只有参数可以是文本,而不是局部变量