开发者

What's the Difference Between the Various Char Types in SQL 2008 R2? [duplicate]

开发者 https://www.devze.com 2023-01-31 00:04 出处:网络
This question already has answers here: Closed 12 yea开发者_如何学Pythonrs ago. Possible Duplicate:
This question already has answers here: Closed 12 yea开发者_如何学Pythonrs ago.

Possible Duplicate:

What is the difference between nchar(10) and varchar(10) in MSSQL?

Can anyone explain the difference between char, nchar, varchar, and nvarchar?


Char is fixed length.

Varchar is variable length, up to the specified length, which will save space.

N denotes Unicode capable types.


Just to add one more explanation you can also use nvarchar(max) and varchar(max). These are variable length fields that can store large amounts of data and are the replacement for the text and ntext datatypes which are deprecated. Do not use the nvarchar(max) orvarchar(max) for evey string field though to avopid having to figure out how big the field should be as they have indexing issues.


the nchar and nvarcar supports Unicode

Nchar(50) or char(50) will always occupy same space irrespective of the size of data.

Nvarchar(50) can store maximum 50 characters but the actual size depends on the data that is stored meaning its flexible , so if the input was 20 characters you can still use the rest elsewhere

0

精彩评论

暂无评论...
验证码 换一张
取 消