gpt4 book ai didi

.net - SQL Server Varbinary(最大): select a subset of bytes from the varbinary field

转载 作者:行者123 更新时间:2023-12-02 08:31:52 36 4
gpt4 key购买 nike

在 SQL Server 2008 中从 varbinary(MAX) 字段(不使用 FileStreams)读取部分二进制数据的最有效方法是什么?

将数据写入列时,T-SQL 中可以使用 VarBinary.Write() 函数,允许将字节增量写入字段,但似乎没有类似的函数可用于读取数据。

我知道 .Net 中的 DataReader.GetBytes() 方法只会选择您要求的字节,但这会带来性能开销吗?即,sqlserver 中的 select 是否会读取数据库中的所有字节,然后为 getBytes() 方法提供所有这些字节,以便它获取从它们请求的字节子集?

感谢您的帮助。

最佳答案

您使用 SUBSTRING 。这会从服务器上的 varbinary 数据中读取一个片段,并且仅将该片段返回给客户端。

[SUBSTRING] Returns part of a character, binary, text, or image expression in SQL Server.. [it] Returns binary data if expression is one of the supported binary data types. The returned string is the same type as the specified expression with the exceptions shown in the table.

关于.net - SQL Server Varbinary(最大): select a subset of bytes from the varbinary field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1288885/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com