常建57

路漫漫其修远兮。。。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Same:

1.store unicode charactor.

2. A charactor is stroed with 2 bytes.

Different.

1. nchar  会自动填充数据到定义的固定长度;nvarchar 是数据有多长就存多少数据。

Example:

Create a table like below and store "A" in the two column.

CREATE TABLE [dbo].[AAAAA](
	[name] [nchar](10) NULL,
	[newName] [nvarchar](10) NULL
) ON [PRIMARY]

   Result:the data length of the name is 20 bytes.

     the data length of the newname is 2 bytes.  

You can get the data length with the below method.

select datalength(name) as Bytes, * from [dbo].[AAAAA]
select datalength(newName) as Bytes, * from [dbo].[AAAAA]

posted on 2014-01-10 10:44  常建57  阅读(96)  评论(0编辑  收藏  举报