Is there a limit to the number of tables in a SQL Server database AND view?

14,786

Solution 1

Well, for limits, you can look at Maximum Capacity Specifications for SQL Server

As another option I would look at using partitioned tables and partitioned indexes.

One of the important things to note here is

The data of partitioned tables and indexes is divided into units that can be spread across more than one filegroup in a database. The data is partitioned horizontally, so that groups of rows are mapped into individual partitions

Which basically states that you can spread the partitions accross various logical file groups. This should provide you with coniderable performance improvements.

Solution 2

SQL Server doesn't have a table limit. Rather, it has an object limit (of which tables are a type of object). So, in effect, the sum of all objects (indexes, views, tables, procs, etc...) can't exceed 2 billion-ish (2,147,483,647 to be pedantic).

There is no hard limit to the amount of joins (or unions) you can have in a single query. The limitation will be hardware related.

Share:
14,786
BlueChippy
Author by

BlueChippy

Updated on June 13, 2022

Comments

  • BlueChippy
    BlueChippy almost 2 years

    I'm working with a database on SQL Server Standard edition that loads data every day - performance of the SQLBulkInsert is slowing down as the table grows and indexing I/O kicks in (even with disable/rebuild, its getting slower)

    So, an alternative suggested to me was to create a view that references each one of the daily tables (or the last 30 for example). Should just be a case of SELECT * FROM x UNION ALL SELECT * FROM y...

    Is there a limit to the number of tables that can be included, or the length of the view definition?
    AND
    Is there a limit to the number of tables in a database?

    OR - is there a better way to do this (without spending any money or I'd move to SQL Server Enterprise and use partitioned tables!)

  • BlueChippy
    BlueChippy over 10 years
    Sorry, but partitioned tables are only in SQL Enterprise, and I am on Standard (and cannot upgrade) :(
  • BlueChippy
    BlueChippy over 10 years
    I guess from the limits it's down to resources to manage the SELECT statement in the view, as opposed to any physical limit on tables/no of characters?
  • user247702
    user247702 over 6 years
    You haven't answered the question, nor does the linked resource have the answer.