سؤال

What is the best way to expand the data in a VARBINARY(max) column, i.e. to set the data to a new length greater than the current length?

-----------------------------------------
| current data      |                   |
-----------------------------------------
                    ^                   ^
                    current length      desired new length

According to MSDN, you cannot set @Offset to a value greater than the data's length, so ... .WRITE (NULL, newOffset, NULL) doesn't work. The best solution I was able to come up with is to Create a binary string of zeros, with variable length, and append it to the data column. Unfortunately this solution produces server-side hangs (which I haven't been able to analyze yet) in a large installation.

What would be a better way to do this? a Am I missing something obvious?

I need this to provide a storage interface to VARBINARY(max) columns. The implementation of this interface is not (yet) aware of the data length, all read/write requests are translated 1:1 to SQL server queries.

هل كانت مفيدة؟

المحلول

Judging by the number of answers, there is no way other than to Create a binary string of zeros, with variable length and append it in a .WRITE query. Others seem to do it similarly: Pre-allocate varbinary(max) without actually sending null data to the SQL Server?.

Posting this just to close the question.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top