简体   繁体   中英

What is the maximum amount of data that can be returned from a sproc in sql server to ADO.NET application

We have a windows service that needs to retrieve all the Orders of a Customer. There can be cases where a customer can have large number of Orders. So wanted to know if there was a known limit on the size of data that can be returned from a sproc in SQL Server to ADO.NET application. I can then calculate the average size of row in the table and provide the max Orders per customer limit. Thanks.

Since you are using ADO.NET, DataReader supports the max data types. You will have to use a batching strategy if you are dealing with massive result sets.

Large object (LOB) data types are those that exceed the maximum row size of 8 kilobytes (KB). SQL Server provides a max specifier for varchar, nvarchar, and varbinary data types to allow storage of values as large as 2^32 bytes. Table columns and Transact-SQL variables may specify varchar(max), nvarchar(max), or varbinary(max) data types. In ADO.NET, the max data types can be fetched by a DataReader , and can also be specified as both input and output parameter values without any special handling. For large varchar data types, data can be retrieved and updated incrementally.

https://msdn.microsoft.com/en-us/library/bb399384(v=vs.110).aspx

I just found following SO post which is also relevant.

SQL Server and SqlDataReader - Trillion Records - Memory

Apparently I cannot repeat this enough: There is no row limit.

The maximum size of a SQL Server database is, if I recall correctly apprx 500,000 terabytes . You are nowhere near that, plus, there is no limit to the number of rows returned . Your interface method might have a limit, but if you are using a .Net streaming method like a datareader , the only limit is your time and patience (and your client's memory or storage if you are trying to retain them all at once).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM