Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server: Maximum character length of object names

People also ask

What is the maximum table name length in SQL Server?

The table name is very important in SQL server. The maximum length of table name characters is 128. There is no limitation for creating tables in SQL server.

Is there a character limit on SQL query?

The maximum standard SQL query length is 1024.00K characters, including comments.

What is the maximum character for a field name?

Field Names can only be a max of 255 characters.

How do I increase character limit in SQL?

Here is how to increase field length in MySQL. Let us say you have a VARCHAR column with length 20, and want to increase its length to 255. In this case, you need to use ALTER TABLE statement to increase column size. ALTER TABLE table_name MODIFY column_name varchar(new_length);


128 characters. This is the max length of the sysname datatype (nvarchar(128)).


Yes, it is 128, except for temp tables, whose names can only be up to 116 character long. It is perfectly explained here.

And the verification can be easily made with the following script contained in the blog post before:

DECLARE @i NVARCHAR(800)
SELECT @i = REPLICATE('A', 116)
SELECT @i = 'CREATE TABLE #'+@i+'(i int)'
PRINT @i
EXEC(@i)

You can also use this script to figure out more info:

EXEC sp_server_info

The result will be something like that:

attribute_id | attribute_name        | attribute_value
-------------|-----------------------|-----------------------------------
           1 | DBMS_NAME             | Microsoft SQL Server
           2 | DBMS_VER              | Microsoft SQL Server 2012 - 11.0.6020.0
          10 | OWNER_TERM            | owner
          11 | TABLE_TERM            | table
          12 | MAX_OWNER_NAME_LENGTH | 128
          13 | TABLE_LENGTH          | 128
          14 | MAX_QUAL_LENGTH       | 128
          15 | COLUMN_LENGTH         | 128
          16 | IDENTIFIER_CASE       | MIXED
           ⋮  ⋮                       ⋮
           ⋮  ⋮                       ⋮
           ⋮  ⋮                       ⋮