Monday, February 20, 2012

NCHAR vs NVARCHAR

In one of the tables i have a column that will always store a single unicode
character. Now , according to theory i should go with NCHAR(1) . But i would
like to know what is the divantage of using NVARCHAR(1) instead of
NCHAR(1) in this case ? is there going to be any extra overhead ?
Thanks
ManishIf you're always storing 1 character us NCHAR(1).
NVARCHAR(1) will require extra storage space to store the length of the data
(using 4 bytes instead of only 2)
NVARCHAR(1) will allow you to store N'' (empty string) which means it needs
to store length.
"Manish Gaur" <ManishGaur@.discussions.microsoft.com> wrote in message
news:79AEFA64-AB85-4262-9317-204D908C6F57@.microsoft.com...
> In one of the tables i have a column that will always store a single
unicode
> character. Now , according to theory i should go with NCHAR(1) . But i
would
> like to know what is the divantage of using NVARCHAR(1) instead of
> NCHAR(1) in this case ? is there going to be any extra overhead ?
> Thanks
> Manish|||You are going to burn 2 extra bytes per row (per column?) as you will need t
o
store the size of the field, even though it is only 1 in length. Not wise.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Manish Gaur" wrote:

> In one of the tables i have a column that will always store a single unico
de
> character. Now , according to theory i should go with NCHAR(1) . But i wou
ld
> like to know what is the divantage of using NVARCHAR(1) instead of
> NCHAR(1) in this case ? is there going to be any extra overhead ?
> Thanks
> Manish

No comments:

Post a Comment