user1987631
user1987631

Reputation:

Proper setting of data type of columns in sql server

I know this is a noob question and I can't find any answer on google, but I want the opinions and suggestions of expert here in sql in terms of setting the data type of columns.

Is it okay if I set all my columns to varchar? even the value of the columns are dates and numbers? Is there any difference if I use Date and Varchar?

I will totally appreciate all the answers, Thank you

Upvotes: 0

Views: 555

Answers (2)

StenW
StenW

Reputation: 2004

The best practice is always a good place to start. Another important issue to take in to consideration is "what is this database for"? If it is for storing dates, why not use dates as the data type. As C0dem0nkey described converting data takes time and with big tables can be quite tricky.

  1. Follow best practice (they are there for a reason).
  2. What is the meaning of this database?
  3. If a choose one over the other what are the consequences?

Upvotes: 1

c0dem0nkey
c0dem0nkey

Reputation: 686

i think doing so will result to an error prone system. How can you use operators on datetime if you use varchar? One way or the other, you have to convert them to datetime just to compare then convert them back to string to store again which takes much much time.

List of Best Practice MySQL Data Types

Here's a helpful post. Regards!

Upvotes: 0

Related Questions