C# .NET - Examples for nvarchar and varchar datatype in sql server 2005

Asked By Priya S on 31-Dec-09 01:27 AM
end of post

re - nvarchar and varchar datatype in sql server 2005

DL M replied to Priya S on 31-Dec-09 01:40 AM

VARCHAR is an abbreviation for variable-length character string. It's a string of text characters that can be as large as the page size for the database table holding the column in question. The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.

The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols — in my case, English and Japanese.

http://blogs.msdn.com/sqlprogrammability/archive/2006/07/07/sql-server-2005-unicode-considerations.aspx

http://dotnetguts.blogspot.com/2007/10/datatypes-in-sql-server-2005.html

re

Web Star replied to Priya S on 31-Dec-09 01:40 AM

varchar has the maximum limit of 8000 characters (when you need to give a particular size), and nvarchar has 4000 characters only (remember it needs double the space needed by a varchar, hence the storage capacity becomes half). Infact a given row in a SQL Server 2000 table cannot exceed 8000 characters in size.

nvarchar store with unicode character also

Right, thanks for ur reply. I want to know what kind of input can be given for the variable which is declared as nvarchar(20) datatype?

Priya S replied to Web Star on 31-Dec-09 01:51 AM

Create table GGG( Materials nvarchar(30))

Now, for the above table created, what will be the values given for the material variable...?

I want different examples of the stored values inside the nvarchar datatype...



re
Santhosh N replied to Priya S on 31-Dec-09 01:53 AM
If your intention is to store unicode characters when working with html or anything related to storing unicode then go for nvarchar or else if wanted to use plain text and numbers then go for varchar...remember that nvarchar requires more space which is double compared to varchar..
Many thanks
Priya S replied to DL M on 31-Dec-09 01:54 AM

I want to know what kind of input can be given for the variable which is declared as nvarchar(20) datatype?

That is consider a table is created with the below Query...

Create table GGG( Materials nvarchar(30))

Now, for the above table created, what will be the values given for the materials variable...?

I want different examples of the stored values inside the nvarchar datatype...

re
Santhosh N replied to Priya S on 31-Dec-09 02:59 AM

Something like this data...

Юникод

Юникод

Re
Huggy Bear replied to Priya S on 31-Dec-09 03:51 AM
nvarchar and varchar are similar data types in SQL server 2005, except the case that varchar field will accept only English text in it where as nvarchar field is useful in storing other language texts (japanese, chinese, etc) as well.
Thanks, you have answered my Question correctly Pal...
Priya S replied to Santhosh N on 31-Dec-09 06:50 AM
end of post
Jonathan VH replied to Priya S on 31-Dec-09 06:53 AM

You can store strings of up to 30 characters, and the characters can be in any language.

The N in nvarchar does not come from the word "unicode;" it stands for "National."

Many languages other than English can be used with varchar data types; just not ones that require double-byte characters.

cheers!
Santhosh N replied to Priya S on 31-Dec-09 07:32 AM
you are welcome!