Min Size of Column Name | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Min Size of Column Name

Is there a minimum size of a column name in sql server? When I create the new column it has brackets wrapped around the name.
[from] What are the brackets used for?
The longer field names don’t have the brackets around them.
From is a SQL Server keyword so the brackets are used to distinguish the column[From] from the keyword FROM as in SELECT [FROM] FROM table A. A good idea is to avoid keywords as column or table names if possible.
I will user sender instead of from. Thanks.

SELECT [User] FROM table A
Maximum length for varchar is 8000 if you want to store more than that use text type
quote:Originally posted by artfuldodger I will user sender instead of from. Thanks.

Its always better not to use SQL keywords as column name as that can lead to poor result.
U can try a column name by checking it in QA whether its a reserver word of SQL or not.
Simply type the column name desired and if the color of text changes from other than black color then its considered to be a SQL word. So u can avoid using such column names. Also avoid column name with space between two words replace spaces with underscores.
eg: user sender
It should be noted that the column name with spaces also should be within []
If the column name is number(not advisible usually), it should also be within []
declare @t table([1] int)
insert into @t values(34)
select 1 from @t –wont return 34 but 1
select [1] from @t –will return 34 Madhivanan Failing to plan is Planning to fail
The Minimum size of column will be adopted when the column is created, check books online for data types topic. Satya SKJ
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.