Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between varchar(41) and varchar(75)

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
My application just recently started blowing up and the problem was traced to one of several new offices my company had acquired. The new office name was 41 characters long and the various office name variables declared in the stored procedures were varchar(40). I opened them all up to 75 in order to be fairly certain that it doesn't happen again if we get an office with 42 or 51 etc characters.

However, is there any downside to creating a generous varchar field rather than making it just big enough plus a little extra?
 
grnzbra,
when you declare a variable as CHAR(n) n bytes are reserved for that variable, no matter if the data is less than n bytes. VARCHAR(n) will allow a maximum of n bytes (characters) to be stored in the variable, however the storage size is the actual length of the data entered, not n. That being said, you should probably increase the size of your variable. The way things are you office might open an office in India or Madagascar one day...
 
That's what I did. I just want to know if there is any reason to hold it down to varchar(50) or something that is "just enough plus a little". Does it slow things down any?
 
Not at all. You can keep data length more with data type varchar. It doesn't effect any thing.

Good Luck
Gopala Krishna Kakani

 

I would not be concerned about going from 40 to 75, it will not cause any problems - In the future you may have to do it anyway.

As far as I know the only issue with using 'oversized' varchar fields is the max length is used when calculating if the total row size excedes the limit of 8060 bytes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top