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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 creating a nvarchar 80 versus 100, any difference?

Author  Topic 

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2008-08-05 : 17:00:46
Hi,

I realize creating a nvarchar(100) is bigger than 80, but say the actual data in the column never exceeds 80.
Does it matter if I declare the field as nvarchar(100) just for safe measure? Will it effect disk usage at all (assuming the data never goes beyond 80).

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-08-05 : 17:10:26
No, varchar and nvarchar stores only 1 byte (or 2 for nvarchar) bytes for every character stored in that row's column. So you are not wasting space by defining the column as nvarchar(100) when you expect the largest value to only be 40 characters.

Be One with the Optimizer
TG
Go to Top of Page

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2008-08-05 : 17:45:34
Ok so even if I am being a little paranoid and making the field a little bigger, its not going to effect row size.

that's great!
Go to Top of Page
   

- Advertisement -