Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Char or Varchar

Author  Topic 

a_shipra
Starting Member

20 Posts

Posted - 2004-08-04 : 23:51:42
I have a column in table called post code which has maximum length = 4.

Can you suggest me that i should use CHAR or VARCHAR?
Also i want to use when should i use char instead of varchar

Thanks

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-08-05 : 00:04:06
Use a CHAR field

CHAR is used when you have a consistent length field.
Go to Top of Page

a_shipra
Starting Member

20 Posts

Posted - 2004-08-05 : 00:36:47
hi timmy,

do you mean that if there is a field of maximum length 50 then also i should use char?
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-05 : 00:45:33
I think it's best to just follow the advice given in Books Online. I make anything over a length of four with a good variance in length a varchar. From BOL:

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.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

a_shipra
Starting Member

20 Posts

Posted - 2004-08-05 : 00:47:44
Thanks for your help
Go to Top of Page
   

- Advertisement -