Kalyani Ramamurthy
Kalyani Ramamurthy

Reputation: 398

What is the best data type to store list of email Ids in database?

My requirement is to store a list of emailIds in a single column, What would be the best data type to do so? My columns are like EmailTo , EmailCC, EmailBCC in which I would require storing the list of Ids. Also , help me with the size of the datatype. I am using SQL server.

Upvotes: 3

Views: 12585

Answers (4)

Jibin Balachandran
Jibin Balachandran

Reputation: 3441

It's good to go with NVARCHAR(320) - 64 characters for local part + @ + 255 for domain name.

You can refer this for more information.

Upvotes: 5

Vladimir Baranov
Vladimir Baranov

Reputation: 32695

The best data type to store a list (any kind of a list, not just e-mail IDs) is a table. Simple table.

For example, if it is a list of integers, the table would have an int column.

This is what RDBMS is for - they are designed to store data in a bunch of tables.


In your case you'd have several tables: EmailsTo, EmailsCC, EmailsBCC. The structure of your tables would depend on what your EmailID is, what type it is and what other related information (columns) you may need.

Upvotes: -1

P Kernel
P Kernel

Reputation: 247

Seems Datatype Issue to me.To answer your question ,in my view VARCHAR(MAX) is the highest that can store up-to 8k characters or may be even more if you cast it, but that would not be the correct approach to do. What you can do is to create a COMMON GROUP and enlist all the email id's to whom you want to send emails. This wont even occupy much of your Datatype space and all peoples can be included within that group as per your comments since you told you require it for sending emails to people.

Upvotes: -2

Aamir M Meman
Aamir M Meman

Reputation: 1831

For email , please use data type as VARCHAR[(n)]

According to defination in MSSQL Server 2008

VARCHAR[(n)] : Describes a variable-length string of single- byte characters.In contrast to the CHAR data type, the values for the VARCHAR data type are stored in their actual length. This data type has two synonyms: CHAR VARYING and CHARACTER VARYING


In building database , I used VARCHAR(45) ,this was working fine for email purposes.

Upvotes: -1

Related Questions