2006/11/28

Maximum column name length in SQL Server 2005

I was asked about this problem today and I could find it neither in SQL Server documentation nor online, so I checked it experimentally.

The name
'test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1
test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1'
is invalid because it is empty, contains invalid characters, or contains
more than 128 characters.


Maximum allowed column name length in SQL Server 2005 is 128 characters.

UPDATE:

As phorku wrote in his comment, the maximum column name length can also be determined by checking properties of the sysname data type:
sysname is a system-supplied user-defined data type that is functionally equivalent to nvarchar(128) and is used to reference database object names

1 comment: