Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 nText vs nVarChar

Author  Topic 

Marioi
Posting Yak Master

132 Posts

Posted - 2005-09-27 : 11:10:49
I am new to SQL Server and would like to hear opinions on pros and cons of using nText vs. nVarChar data type for following uses:

URLs (up to 260 bytes)
Addresses (50-300 bytes)
Descriptions and comments (50-2,000 bytes)
Memos (up to 8000 bytes)

TIA.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-27 : 11:27:53
use nvarchars for all except memos.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-09-27 : 11:29:22
NVARCHAR uses 2-byte characters so only half the "max" data (4000 vs 8000) characters can be stored. If you must support UTF-8 character sets, NVARCHAR is the way to go. If not, stick with VARCHAR for single-character character sets.

TEXT is intended for data in excess of 8000 bytes, but it can't be indexed, so you'll have to design a lookup scheme other than searching for matches in the TEXT column.

There's more on this subject that I'm sure others will contribute.
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2005-09-28 : 10:35:40
Don't use ntext unless no other option. The function which work on string will not work on text data type. like replace, substring.etc..

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-28 : 10:37:13
>>The function which work on string will not work on text data type. like replace, substring.etc..

I think substring will work in Text columns

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2005-09-28 : 10:43:16
Thank you Madhivanan.
I think len is not working on text. I remember i was using datalength on text.

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-28 : 10:56:58
Len, Replace wont work on text columns but Substring will work

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-09-28 : 15:50:16
Use VARCHAR in favour of TEXT where/whenever you can

Kristen
Go to Top of Page

Marioi
Posting Yak Master

132 Posts

Posted - 2005-11-14 : 17:25:41
quote:
Originally posted by madhivanan

Len, Replace wont work on text columns but Substring will work


According to the 'Substring' topic in Books On Line T-SQL reference, text is returned as varchar, image as varbinary and ntext as nvarchar.
Go to Top of Page
   

- Advertisement -