 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Lasse Guest
|
Posted: Sun Jun 29, 2003 11:22 am Post subject: What is the difference between varchar and char |
|
|
What is the difference between varchar and char in ms sql 2000, does it
matter to my delphi app which one I use ?
Using D6, dbexpress
Lasse
|
|
| Back to top |
|
 |
Lasse Guest
|
Posted: Sun Jun 29, 2003 8:45 pm Post subject: Re: What is the difference between varchar and char |
|
|
Are there any pros / cons in regards to performance using varchar or char ?
"Martijn Tonies" <m.tonies@upscene!nospam!.com> skrev i meddelandet
news:3efee9b9 (AT) newsgroups (DOT) borland.com...
| Quote: |
What is the difference between varchar and char in ms sql 2000, does it
matter to my delphi app which one I use ?
CHAR will pad spaces to the end when selecting data, VARCHAR is
a variable length string, without padded spaces.
--
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com
|
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Sun Jun 29, 2003 8:50 pm Post subject: Re: What is the difference between varchar and char |
|
|
"Lasse" <NOSPAMlars-ake.makiaho (AT) telia (DOT) com> wrote
| Quote: | Are there any pros / cons in regards to performance using varchar or char
? |
CHAR fields are stored in-line with the other fixed-length fields whereas
VARCHAR is stored separately which makes CHAR fields marginally faster when
included in a query with other fixed-length records.
OTOH, VARCHAR fields don't require a RTRIM every time you use them, as
trailing spaces are ignored.
Cheers,
Ignacio
|
|
| Back to top |
|
 |
Robert MacLean Guest
|
Posted: Mon Jun 30, 2003 6:31 am Post subject: Re: What is the difference between varchar and char |
|
|
if a have a char(20) then it takes up 20bytes no matter what is in it (even if
it's blank)
if you have a varchar(20) and you have less than 20 characters in it then it
takes up that many characters in bytes (ie 5char = 5bytes). if you have all 20
then it takes 1 extra byte (ie 21bytes for 20 chars).
i had problems using chars with ado, switched to varchar and no problem.
depending on your setup between your app/server and the db the amount of data
may be an issue in which case varchar would be better.
Lasse (NOSPAMlars-ake.makiaho (AT) telia (DOT) com) moved some electrons around
and created the following:
| Quote: | What is the difference between varchar and char in ms sql 2000, does
it matter to my delphi app which one I use ?
Using D6, dbexpress
Lasse
|
--
___________________________________________
Robert MacLean
robert at sadev dot co dot za
Web: http://www.sadev.co.za
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|