Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dean.c4
Starting Member
14 Posts |
Posted - 2011-06-09 : 15:19:29
|
If I'm building an insert stored proc and define one of the params as varchar(max), and nothing gets stuck into this parameter, how much space is wasted or reserved on a basically empty field?In a stored proc, can you define it as varchar() and get the same results or must it say (max) if you truly don't know the length of whats going in there?Thanks. |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-06-09 : 15:47:10
|
I size it to the largest value I intend to allow. If you really don't know, and expect it to be large, use max.Varchar doesn't take any space in row if it is empty. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-09 : 15:47:20
|
It's stores as much as you pass, 0 characters stores 0 bytes of data. You must specify (max) if you intend to store that much. ALWAYS specify a length or max for varchar/nvarchar/varbinary data types. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|