检查连接到 varchar(max) 是否会超出最大允许字符数

Check if concatenating to a varchar(max) will go beyond max allowable characters(检查连接到 varchar(max) 是否会超出最大允许字符数)
本文介绍了检查连接到 varchar(max) 是否会超出最大允许字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个 ID 列表连接到一个 varchar(max) 中,以传递到一个用于批量更新数据的 openquery.

I am trying to concatenate a list of IDs into a varchar(max) to pass into an openquery for a bulk update of data.

我的问题是,除了将字符串与数字进行比较之外,是否有一种简单的方法可以查看字符串是否超出了 varchar(max) 可以处理的长度?

My question is, is there an easy way to see if a string is beyond the length a varchar(max) can handle aside from comparing it to the number?

我见过这个:varchar(max) 中有多少个字符它指定了 varchar(max) 的确切长度,但我希望有一种比将长度与静态数值进行比较更简单的方法.

I have seen this: How many characters in varchar(max) which specifies the exact length of a varchar(max), but I was hoping for a simpler method than comparing length to a static numeric value.

如果需要更多信息,请告诉我.

Please let me know if any more information is needed.

推荐答案

varchar(max) 的最大长度是 2GB 但是 openquery 只需要 8K 根据 在线书籍

The max length of varchar(max) is 2GB however openquery only takes 8K according to Books On Line

OPENQUERY (linked_server ,'查询')参数链接服务器是表示链接服务器名称的标识符.

OPENQUERY (linked_server ,'query') Arguments linked_server Is an identifier representing the name of the linked server.

'查询'是在链接服务器中执行的查询字符串.字符串的最大长度为 8 KB.

'query' Is the query string executed in the linked server. The maximum length of the string is 8 KB.

这篇关于检查连接到 varchar(max) 是否会超出最大允许字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)