Why use anything but varchar(max)

As you might have read I am putting together some standards for data type usage.

When I got to the text stuff varchars are king (generally due to the effort required in an app to trim data), except for small (<4 characters) when I would use char.

My quandry came about what size should a varchar be. With SQL 2005 and the varchar(max) I can't see any benefit not using this everywhere, the result is the same whether you use varchar(10), varchar(2000) or varchar(max). Isn't it.

Ok so with a fixed size datatype SQL will stop you iserting more data than is allowed, but be honest who is relying on SQL to do that validation, not me for one.

and there might be a slight difference in storage, I can't remember how the length or the column is stored but would guess that for < 256 it is 1 byte, < 32,767 its 2 bytes etc.

But using varchar(max) it is definitely future proof, and a lot easier to set standards "always use varchar(max)".

-
Published Tuesday, February 28, 2006 7:16 AM by simonsabin

Comments

# How to: Are there any disadvantages to always using nvarchar(MAX)? | SevenNet

Pingback from  How to: Are there any disadvantages to always using nvarchar(MAX)? | SevenNet

# Fix: Are there any disadvantages to always using nvarchar(MAX)? #it #dev #programming | Good Answer

Pingback from  Fix: Are there any disadvantages to always using nvarchar(MAX)? #it #dev #programming | Good Answer

# Fixed: Are there any disadvantages to always using nvarchar(MAX)? #development #programming #solution | IT Info

Pingback from  Fixed: Are there any disadvantages to always using nvarchar(MAX)? #development #programming #solution | IT Info