Maximum number of records a table variable can have in SQL Server

Are there any restrictions to limit the number of records that we can have in a table variable? If so, what will be the record of the maximum number a table variable can hold? I have to write a stored procedure to process about 1000 records. Do I need to use a table variable or temporary table?

+5
source share
2 answers

Thus, the official MSDN website, where the Maximum Capacity Requirements for SQL Server is , there is no such upper limit defined for table variables, since this depends on the size of the database and the free memory available for storage. You can also access the MSDN forum to discuss it; Maximum Variable Table Capability

Do I need to navigate with a table variable or temporary table?

You can use any of them, since there is no such golden rule as to when you should use the Table variable and when to use temporary variables. There are several links that may be helpful in understanding it:

+8
source

Do you mean a row in a table? Or do you want the variable in some T-SQL to be a table? I assume that you should understand the type table variable, and then the answer is no. The limit of what a table can hold should depend only on the size of your disk. If you want to place a certain number of rows in a table, perhaps use the TOP keyword in a query populating a table? If you provide more detail in the question, you will get a better answer :-)

+1
source

Source: https://habr.com/ru/post/1235333/


All Articles