Questions tagged [nvarchar]

Variable-length character data type in Transact-SQL.

Variable-length character data type in Transact-SQL. More info: https://msdn.microsoft.com/en-us/library/ms186939.aspx.

483 questions
1675
votes
21 answers

What is the difference between varchar and nvarchar?

Is it just that nvarchar supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using varchars?
stimms
  • 42,945
  • 30
  • 96
  • 149
248
votes
14 answers

What are the main performance differences between varchar and nvarchar SQL Server data types?

I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
205
votes
8 answers

nvarchar(max) vs NText

What are the advantages and disadvantages of using the nvarchar(max) vs. NText data types in SQL Server? I don't need backward compatibility, so it is fine that nvarchar(max) isn't supported in older SQL Server releases. Edit: Apparently the…
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
84
votes
7 answers

When must we use NVARCHAR/NCHAR instead of VARCHAR/CHAR in SQL Server?

Is there a rule when we must use the Unicode types? I have seen that most of the European languages (German, Italian, English, ...) are fine in the same database in VARCHAR columns. I am looking for something like: If you have Chinese --> use…
Peter Gfader
  • 7,673
  • 8
  • 55
  • 56
56
votes
3 answers

What's the SQL national character (NCHAR) datatype really for?

As well as CHAR (CHARACTER) and VARCHAR (CHARACTER VARYING), SQL offers an NCHAR (NATIONAL CHARACTER) and NVARCHAR (NATIONAL CHARACTER VARYING) type. In some databases, this is the better datatype to use for character (non-binary) strings: In SQL…
bobince
  • 528,062
  • 107
  • 651
  • 834
46
votes
14 answers

Is VARCHAR like totally 1990s?

VARCHAR does not store Unicode characters. NVARCHAR does store Unicode characters. Today's applications should always be Unicode compatible. NVARCHAR takes twice the amount of space to store it. Point 4 doesn't matter because storage space is…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
44
votes
3 answers

SQL performance: Is there any performance hit using NVarchar(MAX) instead of NVarChar(200)

I am wondering if there is any disadvantage on defining a column of type nvarchar(max) instead of giving it a (smaller) maximum size. I read somewhere that if the column value has more than 4?KB the remaining data will be added to an "overflow"…
willvv
  • 8,439
  • 16
  • 66
  • 101
42
votes
1 answer

How to create NVarchar(max) Sqlparameter in C#?

I've got the following code to pull back a DataTable using a stored procedure and inputting a string parameter @JobNumbers, which is dynamically created string of job numbers (and therefore length is unknown): using (SqlConnection connection = new…
sr28
  • 4,728
  • 5
  • 36
  • 67
34
votes
6 answers

Are there disadvantages to using VARCHAR(MAX) in a table?

Here is my predicament. Basically, I need a column in a table to hold up an unknown length of characters. But I was curious if in Sql Server performance problems could arise using a VARCHAR(MAX) or NVARCHAR(MAX) in a column, such as: 'This time' I…
Meiscooldude
  • 3,671
  • 5
  • 27
  • 30
28
votes
1 answer

Special characters displaying incorrectly after BULK INSERT

I'm using BULK INSERT to import a CSV file. One of the columns in the CSV file contains some values that contain fractions (e.g. 1m½f). I don't need to do any mathematical operations on the fractions, as the values will just be used for display…
MrMatt
  • 305
  • 1
  • 4
  • 6
27
votes
2 answers

What is the performance penalty of XML data type in SQL Server when compared to NVARCHAR(MAX)?

I have a database that is going to keep log entries. One of the columns in the log table contains serialized (to XML) objects and a guy on my team proposed to go with XML data type rather than NVARCHAR(MAX). This table will have logs kept…
Piotr Owsiak
  • 6,081
  • 8
  • 39
  • 42
24
votes
1 answer

Oracle Text will not work with NVARCHAR2. What else might be unavailable?

We are going to migrate an application to have it support Unicode and have to choose between unicode character set for the whole database, or unicode columns stored in N[VAR]CHAR2. We know that we will no more have the possibility of indexing column…
Benoit
  • 76,634
  • 23
  • 210
  • 236
23
votes
1 answer

Difference between NVARCHAR in Oracle and SQL Server?

We are migrating some data from sql server to oracle. For columns defined as NVARCHAR in SQL server we started creating NVARCHAR columns in Oracle thinking them to be similar..But it looks like they are not. I have read couple of posts on…
Zenil
  • 1,491
  • 3
  • 12
  • 21
22
votes
3 answers

Determining Nvarchar length

I've read all about varchar versus nvarchar. But I didn't see an answer to what I think is a simple question. How do you determine the length of your nvarchar column? For varchar it's very simple: my Description, for example, can have 100…
Kane Jeeves
  • 475
  • 2
  • 9
  • 19
21
votes
9 answers

What size to pick for a (n)varchar column?

In a slightly heated discussion on TDWTF a question arose about the size of varchar columns in a DB. For example, take a field that contains the name of a person (just name, no surname). It's quite easy to see that it will not be very long. Most…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
1
2 3
32 33