In this article, I’m going to walk you through everything you need to know about the SQL Server table name length limit. We will cover the standard limits, the “hidden” limits for temporary tables that often catch developers off guard, and the best practices recommended for keeping your schema manageable.
SQL Server Table Name Length Limit
The Short Answer: What Is the Limit?
If you are looking for the quick number to win a trivia bet, here it is:
The maximum length for a standard table name in SQL Server is 128 characters.
This limit applies to what SQL Server calls “Regular Identifiers.” Whether you are creating a table, a view, a stored procedure, or a column, the magic number is almost always 128.
The rules change slightly depending on how you are creating the table (standard vs. temporary) and what characters you are using.
Understanding the sysname Data Type
To understand why the limit is 128 characters, we have to look at the internal data types SQL Server uses to store metadata.
Every time you create a table, SQL Server stores that table’s name in a system view called sys.tables (or sys.objects). If you query the definition of the name column in these system views, you will see it uses a specific data type called sysname.
I consider sysname to be one of the most important built-in types to understand. Internally, sysname is functionally equivalent to NVARCHAR(128) NOT NULL.
Here is why that distinction matters to us:
- It is 128 Characters, not Bytes: Because it is
NVARCHAR(Unicode), it supports 128 characters regardless of language. You can use English characters, Kanji, or Emojis (though I strongly advise against the latter in production!). - It is NOT Nullable: An object must have a name.
- It is System-Wide: This limit is hard-coded into the engine. You cannot change a configuration setting to increase it to 256 or 500.
Temporary Tables: The Hidden “Gotcha”
This is the section where I see most senior developers get tripped up. While standard user tables allow for 128 characters, local temporary tables do not.
When you create a local temporary table (the ones prefixed with a single hash, like #MyTempTable), SQL Server does some behind-the-scenes magic. Since multiple users can create a temp table with the same name (e.g., #OrderList) in their own separate sessions, SQL Server needs a way to differentiate them physically in tempdb.
To do this, SQL Server appends an internal suffix to your table name. This suffix consists of underscores and a hexadecimal hash to ensure uniqueness.
The 116-Character Limit
Because SQL Server needs space for that internal suffix, it “steals” 12 characters from your available limit.
- Standard Table: 128 characters.
- Local Temp Table (
#): 116 characters.
If you try to create a local temporary table with 120 characters, you will receive an error, even though it is under the standard 128-character limit.
Table: Limit Comparison
| Object Type | Syntax Example | Max Length | Notes |
| Standard Table | CREATE TABLE MyTable... | 128 | Defined by sysname. |
| Local Temp Table | CREATE TABLE #MyTable... | 116 | SQL Server reserves 12 chars for internal suffixes. |
| Global Temp Table | CREATE TABLE ##MyTable... | 128 | No internal suffix is added; unique across the server. |
| Table Variable | DECLARE @MyTable TABLE... | 128 | Valid only within the batch scope. |
Do Schema Names Count Toward the Limit?
I often get asked, “Does the 128-character limit include the schema name?”
The answer is no. The limit applies to the identifier itself, not the fully qualified name. SQL Server uses a “Multipart Identifier” system.
When you reference a table as Sales.Orders, you are actually referencing two distinct identifiers:
- Schema:
Sales(Max 128 chars) - Table:
Orders(Max 128 chars)
Theoretically, you could have a fully qualified object name that looks like this:
ServerName.DatabaseName.SchemaName.TableName
Each of those four parts can be 128 characters long. So, your fully qualified string could be well over 500 characters long. However, I have never met a developer who wanted to type that out.
Pro Tip: While the engine allows this, many third-party tools (and even some older Microsoft drivers) might have buffer limits for the total connection string or query text. It is best to keep the total length reasonable.
What Happens When You Exceed the Limit?
SQL Server is very strict about this. Unlike some systems that might silently truncate your name to fit (looking at you, older versions of DB2), SQL Server will throw a hard error.
If you attempt to run a CREATE TABLE statement with a name that is 129 characters long, you will see Error 103:
Plaintext
Msg 103, Level 15, State 4, Line 1
The identifier that starts with 'YourVeryLongTableName...' is too long. Maximum length is 128.This error prevents the object from being created. This is actually a good thing—silent truncation is a nightmare to debug because you might end up with two tables named Transaction_History_Report_202 and Transaction_History_Report_202 (where the original names differed only at the 130th character).
Best Practices for Table Naming
Just because you can use 128 characters doesn’t mean you should.
Here are the guidelines I enforce in my projects:
1. Aim for the “Goldilocks” Zone
I find that the sweet spot for a table name is between 15 and 35 characters.
- Too Short (
T1,Dat): Ambiguous and requires a data dictionary to understand. - Too Long (100+ chars): Annoying to type, clutters IntelliSense, and makes ER diagrams unreadable.
2. Avoid Redundancy
You don’t need to repeat the schema name in the table name.
- Bad:
HR.HR_Employee_Records - Good:
HR.Employees
3. Consider ORM Limitations
If you are using an Object-Relational Mapper (ORM) like Entity Framework, Hibernate, or Dapper, remember that your class names usually map to table names.
A 128-character table name results in a 128-character class name in your C# or Python code. This can make your code verbose and difficult to lint.
4. The “Excel Export” Factor
This is a non-technical constraint that bites many developers. If your data inevitably ends up in Excel, remember that Excel worksheet tabs have a limit of 31 characters.
If you name your table Monthly_Sales_Performance_By_Region_North_America, and you try to export this data to a new tab in Excel named after the table, the export will fail or truncate. Keeping table names under 30 characters ensures smooth interoperability with older tools and Excel.
How to Check Your Current Table Length
If you are auditing an existing database to see who the worst offenders are, you don’t need to count characters manually. I use the metadata views to audit this.
You can use the LEN() function against sys.tables.
Query: Find the Longest Table Names
This query will show you the top 10 longest table names in your current database.
SQL
SELECT TOP 10
name AS TableName,
LEN(name) AS NameLength,
schema_id
FROM sys.tables
ORDER BY NameLength DESC;

Query: Check for “Near Limit” Tables
I also like to check if any tables are dangerously close to the limit, which might block future suffix additions (like _Backup or _Archive).
SQL
SELECT
name AS TableName,
LEN(name) AS NameLength
FROM sys.tables
WHERE LEN(name) > 100
ORDER BY NameLength DESC;
If this query returns rows, I usually flag them for review. If you have a table named with 125 characters, and you ever need to create a backup copy named ..._Bkp, you will hit the 128 limit immediately (125 + 4 = 129) and fail.
Conclusion
The SQL Server table name length limit is 128 characters for standard tables and 116 characters for local temporary tables.
While 128 characters provides a massive amount of flexibility—far more than the 30-character limit of the past, long names increase the cognitive load on your developers, clutter your code, and can cause unexpected integration issues with tools like Excel.
You may also like the following articles:
- SQL Server Table Naming Conventions
- Table Partition In SQL Server Step By Step
- Truncate Table In SQL Server
- Alter table add column at specific position in SQL Server
After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a Microsoft MVP. Check out more here.