Click here to Skip to main content
       

Database

 
QuestionMissing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 4:03 
AnswerRe: Missing Data in an Access Report Pinmemberjschell6-Feb-13 9:11 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 20:01 
GeneralRe: Missing Data in an Access Report Pinmemberjschell7-Feb-13 10:52 
AnswerRe: Missing Data in an Access Report PinmemberMycroft Holmes6-Feb-13 13:27 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 20:06 
GeneralRe: Missing Data in an Access Report PinmemberMycroft Holmes6-Feb-13 21:27 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 21:32 
GeneralRe: Missing Data in an Access Report Pinmemberjschell7-Feb-13 10:56 
Questionoracle error with winserver2008 Pinmemberfares35-Feb-13 2:03 
AnswerRe: oracle error with winserver2008 PinmemberBernhard Hiller5-Feb-13 5:57 
Questionchar(255) vs varchar(255) vs varchar(MAX) Pinmemberdevvvy1-Feb-13 19:22 
AnswerRe: char(255) vs varchar(255) vs varchar(MAX) PinmvpRichard MacCutchan2-Feb-13 0:07 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) [modified] Pinmemberdevvvy2-Feb-13 16:39 
I did but not sure if I interpreted MSDN correctly.

 
char [ ( n ) ]
 
Fixed-length, non-Unicode string data. n defines the string length and must be a value from 1 through 8,000. The storage size is n bytes. The ISO synonym for char is character.
varchar [ ( n | max ) ]
 
Variable-length, non-Unicode string data. n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered + 2 bytes. The ISO synonyms for varchar are char varying or character varying.

 
varchar(255) --- this means SQL server will always allocate 255bytes? Or depending on actual values being inserted for a particular row?
 
If say row 1, "Name" = 25 bytes and row 2, "Name" = 225 bytes (say no other row longer than 225), then...
POSSIBILITY 1: SQL server always allocate 225 bytes (actual length of data, taken from row 2)
POSSIBILITY 2: SQL server always allocate 255 bytes for all rows as defined in column definition varchar(255)
POSSIBILITY 3: SQL Server allocate 25 bytes for row 1, and 225 bytes for row 2 (actual length of data vary from one row to the next)
 
My guess is - POSSIBILITY 3 is how SQL server actually behalves. This said, then why we bother specify varchar(n)? We should always specify varchar(MAX). Two reasons I can think of after a bit of digging...[^]
 
a. You cannot index anything varchar longer than 900 bytes
b. by MAX, you remove column max length validation provided for you at database level.
 
Am I missing something?
dev


modified 2-Feb-13 21:55pm.

AnswerRe: char(255) vs varchar(255) vs varchar(MAX) PinmemberPIEBALDconsult2-Feb-13 6:22 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pinmemberdevvvy3-Feb-13 0:30 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pinmemberjschell3-Feb-13 7:36 
QuestionSP Unexpected Behavior Pinmembereddieangel1-Feb-13 8:19 
QuestionEncrypt a field in the database. Pinmembervanikanc1-Feb-13 6:31 
AnswerRe: Encrypt a field in the database. PinmvpEddy Vluggen1-Feb-13 8:02 
Questioncheck before insert Pinmembervanikanc31-Jan-13 5:55 
AnswerRe: check before insert PinmvpEddy Vluggen31-Jan-13 6:00 
GeneralRe: check before insert PinmvpEddy Vluggen31-Jan-13 11:35 
AnswerRe: check before insert Pinmembermark merrens31-Jan-13 9:10 
GeneralRe: check before insert Pinmembervanikanc31-Jan-13 9:21 
GeneralRe: check before insert Pinmembermark merrens31-Jan-13 11:09 
GeneralRe: check before insert PinmemberChris Meech31-Jan-13 11:24 
GeneralRe: check before insert Pinmembermark merrens31-Jan-13 11:25 
AnswerRe: check before insert Pinmemberdjj551-Feb-13 8:50 
GeneralRe: check before insert Pinmembervanikanc1-Feb-13 8:55 
GeneralRe: check before insert Pinmemberdjj551-Feb-13 9:25 
QuestionIdentify DML changes between two databases PinmemberMember 313707830-Jan-13 21:56 
AnswerRe: Identify DML changes between two databases PinmemberMycroft Holmes30-Jan-13 22:11 
GeneralRe: Identify DML changes between two databases PinmemberMember 313707830-Jan-13 22:26 
QuestionUpdate a flag based on portion of data avialble in other column Pinmemberyuvachandra30-Jan-13 11:20 
AnswerRe: Update a flag based on portion of data avialble in other column PinmemberMycroft Holmes30-Jan-13 12:56 
GeneralRe: Update a flag based on portion of data avialble in other column Pinmemberyuvachandra31-Jan-13 7:08 
GeneralRe: Update a flag based on portion of data avialble in other column PinmemberMycroft Holmes31-Jan-13 12:32 
GeneralRe: Update a flag based on portion of data avialble in other column Pinmemberyuvachandra31-Jan-13 12:45 
GeneralRe: Update a flag based on portion of data avialble in other column Pinmemberyuvachandra1-Feb-13 8:00 
Questionhow to comlex databinding with access database PinmemberAchilles8430-Jan-13 9:48 
AnswerRe: how to comlex databinding with access database PinmemberMycroft Holmes30-Jan-13 12:49 
GeneralRe: how to comlex databinding with access database PinmemberAchilles8430-Jan-13 21:49 
GeneralRe: how to comlex databinding with access database PinmemberMycroft Holmes30-Jan-13 22:06 
GeneralRe: how to comlex databinding with access database PinmemberAchilles841-Feb-13 1:25 
QuestionEnd Case in a Variable Pinmemberberba30-Jan-13 9:47 
AnswerRe: End Case in a Variable PinmemberMycroft Holmes30-Jan-13 12:46 
GeneralRe: End Case in a Variable Pinmemberberba30-Jan-13 19:02 
GeneralRe: End Case in a Variable PinmemberMycroft Holmes30-Jan-13 21:57 
QuestionWhat happens with auto-incremented value on rollback? Pinmemberpiticcotoc30-Jan-13 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 21 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid