Home > SQL > BISQL # 41 : Difference Between Char And Varchar

BISQL # 41 : Difference Between Char And Varchar

 

Hi Friends,

One of my dearest friends is asking for Difference Between Char And Varchar. I feel its very simple but after having long conversation with her I realize we should have differentiation article based on same.

Sites supporting multiple languages should consider using the Unicode nchar or nvarchar data types to minimize character conversion issues. If you use char or varchar:

  • Use char when the data values in a column are expected to be consistently close to the same size.
  • Use varchar when the data values in a column are expected to vary considerably in size.

If SET ANSI_PADDING is OFF when CREATE TABLE or ALTER TABLE is executed, a char column defined as NULL is handled as varchar.

When the collation code page uses double-byte characters, the storage size is still n bytes. Depending on the character string, the storage size of n bytes may be less than n characters.

What’s the difference between CHAR and VARCHAR?

The short answer is: VARCHAR is variable length, while CHAR is fixed length.

In the following difference you may find some point keep repeated but I think I don’t want reader to get confused when the refer to other blog and have whole bunch of differentiation in single table

Please click on image if its look in smaller font Smile

image

When should We use CHAR instead of VARCHAR?

The short answer is: Almost never.

Hope this helps !!!

 

For more interesting information on SQL we can also look into similar topics such as

· BISQL # 42 : How to find count of all the records in all the table

· BISQL # 43 : Introduction to DAC – Data-Tier Application {DAC Part – I}

· BISQL # 44 : DAC-Database Project Overview {DAC Part – II}

· BISQL # 45 : How to Rename .MDF File and .LDF file ? (i.e – .mdf , .ldf)

· BISQL # 46 : Information of SQL Server Database Services and Startup account

 

Hope you will like this post on Difference between Char & Varchar.

If you really like reading my blog and understood at least few thing then please don’t forget to subscribe my blog.

If you want daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog : Link Resource Website

                For More information related to BI World visit my Mentalist Blog

                           Link Resource Blog >> Daily Interesting links

                           SQL Server Mentalist >> SQL Learning Blog

                           Business Intelligence Mentalist >> BI World

                                     Connect With me on

           | FaceBook |Twitter | LinkedIn| Google+ | WordPress | RSS |

                                  Copyright © 2011 – 2012 Vishal Pawar

Advertisements
Categories: SQL
  1. D.Asuncion
    October 20, 2011 at 1:15 pm

    Great Article.

    • October 30, 2011 at 2:26 am

      Thank for the comment Asuncion !! Really Appricated u r valuable feedback !!

  2. D.Asuncion
    October 20, 2011 at 1:16 pm

    Thank you.

  1. August 18, 2011 at 10:23 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: