I have a person table that will have columns such as first name and last name.
What is the best data type to use for these columns as they can be any length. Is there a rule of thumb when it comes to this?
I am using sql server 2008.
I have a person table that will have columns such as first name and last name.
What is the best data type to use for these columns as they can be any length. Is there a rule of thumb when it comes to this?
I am using sql server 2008.
I think it is highly unlikely someone to have a Firstname or Lastname more than 50 characters. Datatype for string type with Unicode characters is NVARCHAR and you can limit both of them to 50 or even 100 would not make a much difference.
So you can say
Firstname nvarchar(50)
Lastname nvarchar(50)
Use NVARCHAR(N), where N is the largest number of characters you wish to support for the field.
If you expect that you will never have international names (say Chinese, Japanese, Hebrew and other scripts) than you can use VARCHAR(N).
These are variable length fields that are suitable for string data of variable length.