Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase «««1234

Data Type and Length Expand / Collapse
Posted Tuesday, September 28, 2010 3:02 AM



Group: General Forum Members
Last Login: Yesterday @ 8:25 PM
Points: 7,765, Visits: 11,373
David Data (9/28/2010)
OTOH I designed our ETL system with [Postcode] [nvarchar](10) and then had to change it when I found records with postcodes like 'If out please leave by back door or with neighbour at No. 127'

I really hope your design change was to add a column for "delivery comments", not to increase the maximum length for the postcode. (Unless your business operates in a country where 'If out please leave by back door or with neighbour at No. 127' is a valid postcode).
But I do hope you changed the postcode to varchar(10). As far as I know, all countries in the world that use postal codes limit them to numbers and the letters A-Z.

Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog:
Post #994259
Posted Thursday, September 30, 2010 10:05 PM



Group: General Forum Members
Last Login: Yesterday @ 9:30 PM
Points: 42,060, Visits: 39,443
David Data (9/27/2010)
But I am curious as to why a VARCHAR(MAX) string that happens to contain say 100 chars is so much slower that a VARCHAR(100) that does? Its index and length values will have to be 32 bit numbers, but with 32/64 bit CPUs anything shorter tends to be less rather than more efficient anyway. As even a VARCHAR(100) is stored as a variable length string, I would not imagine the memory management issues are much different either. Or are they?

Im not sure. Some folks insist (and maybe rightfully so... I seem to remember such a thing in BOL but don't remember for sure) the VARCHAR(MAX) stays "inrow" under such conditions. To me, it seems like it may not but I've not taken the time to research that to any depth. It would be nice to know for sure but I just don't have the floor space on my dance card right now.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

Helpful Links:
How to post code problems
How to post performance problems
Post #996400
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse