A simple question, but I think it deserves it's place out here for an answer.
一个简单的问题,但我认为它应该在这里给出答案。
I have a T-SQL statement:
我有一个T-SQL语句:
select Name
from MyTable
where ID IN (1,2,3,4,5,.....)
How many comma-delimited IDs can I put in this select before SQL breaks? Will it break?
在SQL中断之前,我可以在这个select中输入多少逗号分隔的id ?它会打破吗?
1 个解决方案
#1
4
The maximum length of the list is only restricted by the maximum batch size which is 65536 network packets. A network packet is 4 KB by default. So that makes about 268 MB of T-SQL text. If you take an average length of 10 digits per element including the separating ,
you can put about 25 million separate values in there still leaving room for the rest of the query.
该列表的最大长度仅限制于最大批量大小,即65536网络包。默认情况下,网络数据包是4 KB。这就产生了268 MB的T-SQL文本。如果对每个元素(包括分隔符)取平均长度为10位,则可以在其中放置约2,500万个独立值,仍然为查询的其余部分留有空间。
See: Maximum Capacity Specifications for SQL Server
参见:SQL Server的最大容量规范
#1
4
The maximum length of the list is only restricted by the maximum batch size which is 65536 network packets. A network packet is 4 KB by default. So that makes about 268 MB of T-SQL text. If you take an average length of 10 digits per element including the separating ,
you can put about 25 million separate values in there still leaving room for the rest of the query.
该列表的最大长度仅限制于最大批量大小,即65536网络包。默认情况下,网络数据包是4 KB。这就产生了268 MB的T-SQL文本。如果对每个元素(包括分隔符)取平均长度为10位,则可以在其中放置约2,500万个独立值,仍然为查询的其余部分留有空间。
See: Maximum Capacity Specifications for SQL Server
参见:SQL Server的最大容量规范