SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Varchar or Char?


Varchar or Char?

Author
Message
macrostarrphish
macrostarrphish
SSC-Enthusiastic
SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)SSC-Enthusiastic (159 reputation)

Group: General Forum Members
Points: 159 Visits: 155
We need to define a column that will contain externally provided identifiers. Their

(1) length will vary from seven to ten characters
(2) all English letters
(3) both upper and lower case mixed with numeric digits
(4) with an even distribution of lengths <--missed this point when answering, thus got it wrong [I said varchar(10)]

Which of these data types will be more efficient?

Correct answer nvarchar(25)...

Because...
(1) I don't care how many people you asked in management, this will change next week as soon as this is in PROD...you know that's true
(2) for now, but when you least suspect it/expect it you will have worry about localization...
(3) anh, moot point...see point 2
(4) unless this is a lookup table, this can only be the case if the number of records is evenly divisible by four, as you add one record at a time...unless all your batch inserts are also divisible by four and only then do you insert.

good question though, since the parameters were set as hypotheticals, but in the 'real' world those first set of constraints ALWAYS are wrong...LOL
Samith C
Samith C
SSC Veteran
SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)SSC Veteran (290 reputation)

Group: General Forum Members
Points: 290 Visits: 163
Realy good Question
keep it up John :-)

There is no Wrong time to do a Right thing Smile
Junior Galvão - MVP
Junior Galvão - MVP
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3714 Visits: 217
Hi,

It is great question.

Congrats.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search