473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

nvarchar vs varchar in .net application

My collegue is saying that you should store text data in Sql Server i
unicode fields (nvarchar) beause that .net (asp.net website) is all
unicode and therefore you save some time not having to convert the data

from ascii to unicode.

So i thought that i should ask you experts what you saying about it?
What is best for performance if you do not have to store any unicode
characters? It's a kind of big table with about 2 million rows.

Br, Ola

Ps. I double posted this in the SQL usegroup to, i want answers from a
diffrent audience since a DB experts and a dotnet experts might have
diffrent views on this .. hope it's ok?

Dec 15 '06 #1
4 2123
Hi,

Using that logic you could also say that since Unicode characters take up
twice as much space that any parsing operations performed on them would take
twice as long, but I doubt you'll see any performance benefit using one over
the other, to be realistic, unless you're application is constantly
parsing/storing database text at an exorbitant rate. It's most likely going
to be the connection to the database that causes any performance
degradation, especially if you're using pessimistic concurrency.

I say choose the one that fits the data domain and forget about performance.
If you want, you could runs some stress tests using both and see which one
performs best if you think it'll make a difference.

--
Dave Sexton

<st******@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
My collegue is saying that you should store text data in Sql Server i
unicode fields (nvarchar) beause that .net (asp.net website) is all
unicode and therefore you save some time not having to convert the data

from ascii to unicode.

So i thought that i should ask you experts what you saying about it?
What is best for performance if you do not have to store any unicode
characters? It's a kind of big table with about 2 million rows.

Br, Ola

Ps. I double posted this in the SQL usegroup to, i want answers from a
diffrent audience since a DB experts and a dotnet experts might have
diffrent views on this .. hope it's ok?

Dec 15 '06 #2
Hi,
I agree with Dave...

Moreover, using unicode will allow you to translate your website at will
when you become ready for it because everything is already stored in unicode
fields. So let's say you have to translate to Spanish or Russian, you will
need to have unicode fields to store your things... Even if you don't
translate... if a user register with a name containing unicode characters
he will be able to enter his real name rather than trying to fin an
equivalent with ascii chars... I'd say stick with unicode unless you find a
REAL BIG problem with it, but I don't will you will find any... ;)

By using unicode, performance won't be a problem unless you process a heavy
load of data and space issue can be resolved at very low costs these days...
so no big problems ahead... But if you use ascii, you will be stuck to
english, french and some other latin languages (maybe not all of them) and
you may have encoding problems between systems such as pc to mac or event on
linux because the extended characters table can change from one country to
another so there's not guarantee your page will look the same everywhere,
but using unicode will...

I hope it helps

ThunderMusic
"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OV**************@TK2MSFTNGP04.phx.gbl...
Hi,

Using that logic you could also say that since Unicode characters take up
twice as much space that any parsing operations performed on them would
take twice as long, but I doubt you'll see any performance benefit using
one over the other, to be realistic, unless you're application is
constantly parsing/storing database text at an exorbitant rate. It's most
likely going to be the connection to the database that causes any
performance degradation, especially if you're using pessimistic
concurrency.

I say choose the one that fits the data domain and forget about
performance. If you want, you could runs some stress tests using both and
see which one performs best if you think it'll make a difference.

--
Dave Sexton

<st******@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
>My collegue is saying that you should store text data in Sql Server i
unicode fields (nvarchar) beause that .net (asp.net website) is all
unicode and therefore you save some time not having to convert the data

from ascii to unicode.

So i thought that i should ask you experts what you saying about it?
What is best for performance if you do not have to store any unicode
characters? It's a kind of big table with about 2 million rows.

Br, Ola

Ps. I double posted this in the SQL usegroup to, i want answers from a
diffrent audience since a DB experts and a dotnet experts might have
diffrent views on this .. hope it's ok?


Dec 15 '06 #3
There is likely much more points that could badly hit performance before
this (still theoricall for now) one. Generally use what makes sense for your
application regardless of theorical considerations (testing would be a first
move, then use unicode if you prove it's significantly faster than varchar).

For now, the very first question is do you want to support unicode for your
website ? If yes use nvarchar, if not use varchar...

--
Patrice

<st******@gmail.coma écrit dans le message de news:
11**********************@80g2000cwy.googlegroups.c om...
My collegue is saying that you should store text data in Sql Server i
unicode fields (nvarchar) beause that .net (asp.net website) is all
unicode and therefore you save some time not having to convert the data

from ascii to unicode.

So i thought that i should ask you experts what you saying about it?
What is best for performance if you do not have to store any unicode
characters? It's a kind of big table with about 2 million rows.

Br, Ola

Ps. I double posted this in the SQL usegroup to, i want answers from a
diffrent audience since a DB experts and a dotnet experts might have
diffrent views on this .. hope it's ok?

Dec 15 '06 #4
Patrice <sc****@chez.comwrote:
There is likely much more points that could badly hit performance before
this (still theoricall for now) one. Generally use what makes sense for your
application regardless of theorical considerations (testing would be a first
move, then use unicode if you prove it's significantly faster than varchar).

For now, the very first question is do you want to support unicode for your
website ? If yes use nvarchar, if not use varchar...
There's slightly more to it than that: you can support Unicode for the
website but still have an internal product code which would only ever
be in ASCII, for instance.

I would say it's a good idea to use varchar for fields that you
definitely, definitely don't need to contain any non-ASCII data, either
now or in any reasonably forseeable future - but anything else, use
nvarchar.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vani Kancherlapalli | last post by:
Hi The maximum length of a nvarchar could be 4000 characters while that of varchar could be 8000. We are trying to use unicode which would require that the datatype for one our fields be...
7
by: Oleg Ogurok | last post by:
Hi all, I need to store data into about 104 columns. This is problematic with MS SQL, since it doesn't support rows over 8kb in total size. Most of the columns are of type NVARCHAR(255), which...
4
by: wriggs | last post by:
Hi, This is probably an easy question for someone so any help would be appreciated. I have changed the columns in a table that where nvarchar to the same size of type varchar so halve the...
4
by: D. | last post by:
Hi, I'm starting a new application in java using JTDS jdbc driver (http://jtds.sourceforge.net) and SQLServer 2005 Express. I have to design the database from scratch and my doubt is if I have to...
1
by: Srikanthk | last post by:
Dear Sir, What is the Difference using varchar and nvarchar in Oracle 9i.
5
by: haidani | last post by:
Hi, I am new to MS SQL. When I create a column in a table, when shall I use nvarchar or varchar? Please help. Thanks, Mike
2
by: bharathreddy | last post by:
Here i will show the differences between nvarchar and varchar: The difference is that nvarchar is used to store unicode data, which is used to store multilingual data in the database tables....
2
by: Mark B | last post by:
When I click the 'Update' button on a ASP.Net 3.5 GridView record, I get an error: Incorrect syntax near 'nvarchar'. Everything else there works OK. Here is the code: <%@ Page...
1
by: leedatkinson | last post by:
Hi, I'm pretty new to using SQL as a long standing Access users all these field types are a bit much... I have a ntext field that I need to convert to a nvarchar. I have tried cast and convert and as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.