3

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.

1

4 Answers 4

5

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this. Its as i thought. There's no magic datatype that auto expands as needed. This is my accepted answer
3

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.

Comments

1

You can use Varchar(50) data type and devide full name in to first name, middle name and l

Comments

1

If any lenght can acceed 4000 for NVarchar or 8000 for Varchar you could use (N)Varchar(max). But if this would be unlike you should prefer (N)Varchar(Yourlimit) because of perfomance issues.

Ref1 and Ref2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.