code_junkie

Overcome 8k limit to sql server stored procedure parameter

Nov 13th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. @chunck binary(8000),
  2. @result_id int
  3.  
  4. as
  5.  
  6. declare @pointer binary(16),
  7. @imagelength int,
  8. @datalength int
  9.  
  10.  
  11. --get the pointer and length to the image column
  12. select @pointer = textptr(result_image),
  13. @imagelength = datalength(result_image)
  14. from dbo.dash_result
  15. where result_id = @result_id
  16.  
  17. if @pointer is null
  18.  
  19. update dbo.dash_result
  20. set result_image = @chunck
  21. where result_id = @result_id
  22.  
  23. else
  24.  
  25. begin
  26.  
  27. --append the chunck of data to the end
  28. set @datalength = datalength(@chunck)
  29. updatetext dbo.dash_result.result_image @pointer @imagelength 0 @chunck
  30.  
  31. end
Add Comment
Please, Sign In to add comment