.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

What is the Difference Between nchar(n) and nvarchar(n)?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

Hi, What is the difference between these two data types in SSCE 4.0:

nchar(n) and nvarchar(n)

The documentation here states for nchar(n):

Fixed-length Unicode data with a maximum length of 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered.

and for nvarchar(n):

Variable-length Unicode data with a length of 1 to 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered.

I presume by "number of characters entered" it is meant "number of characters stored for the column value in the table row". But if that is true, it is not clear to me how nchar is "fixed-length", nor how it is different to nvarchar.

Any help with this would be much appreciated.

Many thanks.

Regards Martin


View Complete Post

More Related Resource Links

How do I suppress the creation of nchar(), nvarchar()

Some of the wizards and import tools that create tables use nchar() and nvarchar() for character fields. Also the upgrade wizard from Access does the same thing. Is there a way to prevent the creation of nchar() and varchar() fields and to use char() and varchar()? Is there some TSQL I can use to pass over the exisitng tables and conver the datatypes?

What is the difference between "dynamic" and "object" keywords?

Let's take a quick look at the object keyword first. I'm not going to talk a lot about it because it's been around since C# 1.0. This keyword is nothing more than a shortcut for System.Object, which is the root type in the C# class hierarchy. (However, as Eric Lippert pointed out in his blog post, not everything in C# derives from object.) This is a powerful mechanism, since you can assign almost any value to instances of this type.

.net difference between versions


 what is the difference between .net 2.0/3.0/ 3.5

Difference Btw Website vs Web application and Virtual directory in IIS 7


May i know what is the Differenc that they actually make in IIS7 .

Please tell me at a low level as i am still a novice in Asp.Net


Thanks in Advance.


Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

I need help about nvarchar field



how can specified nvarchar data type without N''?

Difference between normal DLL & .net DLL


Hi All,

What is a difference between a regular DLL & .net DLL ?

Thanks in adavnce

Need function to find difference between two dates


Hi all

I need a function written in vb to find the exact month difference between two dates.

For example

    Start Date : 01/01/2010

    End Date   : 15/02/2010

 then the difference value should be like this 1.5  i.e i need the difference in decimal value.

difference between GetPostbackEventReference and GetCallbackEventReference



Hi All,

I was working with these two methods of ClientScriptManager class, but still not able to understand it properly.

Any one  have work on experience with these methods, want to know the difference between

GetPostbackEventReference and GetCallbackEventReference.

Friends, please dont post any urls. I also searching through different articles, but seened only definitions without any proper explained examples.

Time Difference in Linq queries


Hi All,


I have my Linq query in which i need to find time difference(not days difference).

The field in database is datetime.

Dim ldtToday As DateTime = TimeOfDay

Dim SR_RM_InnerJoin = From SR In lcntxRT60Entities.RtSReports _

Join RM In lcntxRT60Entities.RtRMaster On SR.RtRMaster.ReportID Equals RM.ReportID _

Select SR, RM _

Difference between String and string in C#



Can somebody explain to me the difference between String and string in C#?



Conversion Failed when Converting the nvarchar value 'N' to data type int.

Hi.. I am facing a strange situation. when i executing the following query it is returning the error SELECT  s.row_id as shipment,    SUM(CAST(la5.attr_value AS INT)) AS Cases     FROM    shipment s WITH(NOLOCK)    INNER JOIN shipping_shift ss WITH(NOLOCK) ON s.shipping_shift = ss.row_id    INNER JOIN shift WITH(NOLOCK) ON ss.shift_id = shift.shift_id    INNER JOIN shipment_lot sl WITH(NOLOCK) ON s.po_id = sl.po_id AND s.cust_id = sl.cust_id AND          s.so_line_no = sl.so_line_no and s.ship_date_local = sl.ship_date_local     INNER JOIN lot_attr la5 WITH(NOLOCK) ON sl.lot_no = la5.lot_no AND sl.item_id = la5.item_id AND la5.attr_id = (SELECT attr_id FROM attr WITH(NOLOCK) WHERE attr_desc = 'CaseQty' AND attr_grp = 3)  WHERE s.spare2 = 'RELEASED'       AND shift.shift_desc = 'c'   AND DAY(ss.production_date) = DAY('2010-08-09 00:00:00.000')    AND MONTH(ss.production_date) = MONTH('2010-08-09 00:00:00.000')    AND YEAR(ss.production_date) = YEAR('2010-08-09 00:00:00.000') GROUP BY s.row_id  Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the nvarchar value 'N' to data type int. The column  type of attr_value of lot_attr table is a USER D

difference between win 2003 Ent and Win 2008 Ent

what is difference between win 2003 Ent and win 2008 ent in clustering environment?

How to store binary data as nvarchar(max)?

I’m trying to store a blob of binary data as nvarchar(max) and it gets truncated after just a few bytes. I wonder why and how can I prevent it. I don’t use varbinary(max) because I’m trying to keep existing DB schema intact. Current DB contains a huge chunks of text in nvarchar(max) column and I’m trying to compress (zip) this text and store it back to the same field to reduce DB size.   DB is accessed using Sync Framework (and Entity Framework) on the client side, so actual DB engine is SQL Server Compact 3.5 SP2   Thank you! KonstantinThank you! Konstantin

What is the difference in these two approaches of using SQL server databse?

Using - VS 2005, SQL Server 2005 Expresss, C# WinForms App What is the difference in these two approaches of using SQL server databse?   approach 1 -> directly connect to sql server and use an available, preexisting database   approach 2 -> add a SQL Database file to ur WinForm app and connect to it Are these things right abt these alternatives?  - approach 2 means SQL Server CE database  - approach 2 will b better for deployment as databse file will reside in app folder. i m new to SQL Server. I used to worrk with ms access only. Please help?Vibhor Agarwal

What is the difference between component,tier and layer?

We often heard about these word  like component, tier, layer of an asp.net application. Please explain the difference between  component , tier and layer?We often heard about these word  like component, tier, layer of an asp.net application.Please explain the difference between  component , tier and layer?

Difference between Rating and RatingExtender control in ajax control toolkit

Hi, Can you tell the difference between Rating and RatingExtender asp.net ajax Control ? 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend