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 |
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2004-11-05 : 07:01:56
|
| How important is the 'Length' of a table field.Does it mean that this field cannot contain data more than the lenght of this field.What happens, if I try to insert data into this field which is more than the length. When designing a table, does it matter if I create large field lengths. e.g does it affect performace...etckind regards |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-11-05 : 07:22:39
|
| in short.1. very2. yes3. chop off and discard the extra data4. it can....unused space still has to be traversed to get to populated data....it also costs money. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-05 : 07:59:58
|
| Errrmmm ... I think 3 is error "String or binary data would be truncated"4 if varchar then there is no wasted space is there?Kristen |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-05 : 08:08:24
|
| If you get "String or binary data would be truncated" then the row is not inserted. A multi-row operation would fail and no rows would be inserted:create table #duh(a varchar(4) not null)insert #duh select '123' union allselect '1234' union allselect '12345'select * from #duhdrop table #duhVarchar won't store more data than the length of the value, but it may still "waste" some space. If you update a varchar column from 1000 bytes to 500, that now-empty space will not be reclaimed or reused on the data page unless the table was reindexed (even then it may not be reused) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-05 : 08:33:04
|
| "update a varchar column from 1000 bytes to 500"Good point, hadn't thought of that.Kristen |
 |
|
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2004-11-05 : 08:56:45
|
| Any difference between nvarchar & charvar.I always tend to use nvarchar |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-11-05 : 09:22:05
|
| the 'n' versions are only worthwhile/needed if you have some form of internationalisation to worry about, particularly support for asian and/or arabic character sets.otherwise for plain old english data, you would double the size of the dataspace compared to the 'non-n' versions of the columns. |
 |
|
|
|
|
|