Firebird 数据库 BLOB 类型为 20,000 字节,SQL 服务器数据类型用于存储 blob?

Firebird database BLOB type with 20,000 bytes, which SQL Server data type to store blob?

正在将数据从 Firebird 数据库迁移到 SQL 服务器。有一个 BLOB 二进制字段,其值约为 20,000 字节,使用 OCTET_LENGTH 函数测量。

哪种 SQL 服务器数据类型将容纳超过 8000 字节?

与 Firebird BLOB SUB_TYPE BINARY(或 BLOB SUB_TYPE 0BLOB 没有显式子类型)最接近的等价物是 VARBINARY(MAX)。见 binary and varbinary (Transact-SQL):

varbinary [ ( n | max) ] Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. The data that is entered can be 0 bytes in length. The ANSI SQL synonym for varbinary is binary varying.

这些类型的值的访问方式存在一些差异(取决于所使用的 API)。在 Firebird BLOB 中,值存储 off-row 并单独访问(尽管某些 API 会向您隐藏这一点),而 - IIRC - 在 SQL 服务器中,VARBINARY 值存储 on-row 和 APIs 将允许您直接访问该值。