t-sqlsql-server-2008-r2

Does the 128 character limit for table names include the database name and schema name?


Microsoft's Database Objects documentation states that table names can only be 128 characters. Does this include the Schema name? What about the database name?

For example, if I needed to run the following sql statement that copies all data in a source table to a destination table in a different database, I'd write:

SELECT *
INTO DestinationDatabase.DestinationSchema.DestinationTable
FROM SourceDatabase.SourceSchema.SourceTable

Now say I have a table that stores the database name, schema name, and table name for both the source and the destination tables, what size limit should I put on the columns storing these names?

Is it a 128 character limit for each part (database name, schema name, table name) or should the entire identifier (like DestinationDatabase.DestinationSchema.DestinationTable) only be up to 128 characters long?


Solution

  • It's length of sysname data type nvarchar(128). It's per element (so for table separately 128).