Click here to Skip to main content
15,902,939 members
Home / Discussions / Database
   

Database

 
QuestionIs it possible to print a variable in stored procedure Pin
Deepthi.214567-Feb-13 19:45
Deepthi.214567-Feb-13 19:45 
AnswerRe: Is it possible to print a variable in stored procedure Pin
nainakarri7-Feb-13 20:22
nainakarri7-Feb-13 20:22 
GeneralRe: Is it possible to print a variable in stored procedure Pin
vanikanc12-Feb-13 8:19
vanikanc12-Feb-13 8:19 
QuestionVisual Studio 2005 Access 2010 Database Pin
Member 98194707-Feb-13 12:06
Member 98194707-Feb-13 12:06 
AnswerRe: Visual Studio 2005 Access 2010 Database Pin
Mycroft Holmes7-Feb-13 13:45
professionalMycroft Holmes7-Feb-13 13:45 
QuestionSimulate transaction: non blocking insert / update Pin
Bob Stanneveld7-Feb-13 11:12
Bob Stanneveld7-Feb-13 11:12 
AnswerRe: Simulate transaction: non blocking insert / update Pin
Mycroft Holmes7-Feb-13 13:44
professionalMycroft Holmes7-Feb-13 13:44 
QuestionPropagating a MySQL transaction with MSMQ II Pin
Ger Hayden6-Feb-13 8:08
Ger Hayden6-Feb-13 8:08 
QuestionMissing Data in an Access Report Pin
Vimalsoft(Pty) Ltd6-Feb-13 3:03
professionalVimalsoft(Pty) Ltd6-Feb-13 3:03 
AnswerRe: Missing Data in an Access Report Pin
jschell6-Feb-13 8:11
jschell6-Feb-13 8:11 
GeneralRe: Missing Data in an Access Report Pin
Vimalsoft(Pty) Ltd6-Feb-13 19:01
professionalVimalsoft(Pty) Ltd6-Feb-13 19:01 
GeneralRe: Missing Data in an Access Report Pin
jschell7-Feb-13 9:52
jschell7-Feb-13 9:52 
AnswerRe: Missing Data in an Access Report Pin
Mycroft Holmes6-Feb-13 12:27
professionalMycroft Holmes6-Feb-13 12:27 
GeneralRe: Missing Data in an Access Report Pin
Vimalsoft(Pty) Ltd6-Feb-13 19:06
professionalVimalsoft(Pty) Ltd6-Feb-13 19:06 
GeneralRe: Missing Data in an Access Report Pin
Mycroft Holmes6-Feb-13 20:27
professionalMycroft Holmes6-Feb-13 20:27 
GeneralRe: Missing Data in an Access Report Pin
Vimalsoft(Pty) Ltd6-Feb-13 20:32
professionalVimalsoft(Pty) Ltd6-Feb-13 20:32 
GeneralRe: Missing Data in an Access Report Pin
jschell7-Feb-13 9:56
jschell7-Feb-13 9:56 
Questionoracle error with winserver2008 Pin
fares35-Feb-13 1:03
fares35-Feb-13 1:03 
AnswerRe: oracle error with winserver2008 Pin
Bernhard Hiller5-Feb-13 4:57
Bernhard Hiller5-Feb-13 4:57 
Questionchar(255) vs varchar(255) vs varchar(MAX) Pin
devvvy1-Feb-13 18:22
devvvy1-Feb-13 18:22 
AnswerRe: char(255) vs varchar(255) vs varchar(MAX) Pin
Richard MacCutchan1-Feb-13 23:07
mveRichard MacCutchan1-Feb-13 23:07 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pin
devvvy2-Feb-13 15:39
devvvy2-Feb-13 15:39 
I did but not sure if I interpreted MSDN correctly.
<br />
<br />
char [ ( n ) ]<br />
<br />
    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.<br />
varchar [ ( n | max ) ]<br />
<br />
    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) Pin
PIEBALDconsult2-Feb-13 5:22
mvePIEBALDconsult2-Feb-13 5:22 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pin
devvvy2-Feb-13 23:30
devvvy2-Feb-13 23:30 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pin
jschell3-Feb-13 6:36
jschell3-Feb-13 6:36 

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

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