BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is the difference between varchar and char

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Lasse
Guest





PostPosted: Sun Jun 29, 2003 11:22 am    Post subject: What is the difference between varchar and char Reply with 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



Back to top
Lasse
Guest





PostPosted: Sun Jun 29, 2003 8:45 pm    Post subject: Re: What is the difference between varchar and char Reply with quote



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





PostPosted: Sun Jun 29, 2003 8:50 pm    Post subject: Re: What is the difference between varchar and char Reply with quote



"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





PostPosted: Mon Jun 30, 2003 6:31 am    Post subject: Re: What is the difference between varchar and char Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.