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
20
votes
5 answers

Nvarchar or varchar what is better use multiply of 2 or rounded full numbers?

My question is what is better to use in generating columns in SQL. Should the size of nvarchar (varchar) be multiply of 2 (32, 64, 128) or it's doesn't matter and we can use fully numbers example '100', '50' ? Thank You very much for answers with…
szkra
  • 1,423
  • 2
  • 14
  • 21
18
votes
3 answers

What is the point of COLLATIONS for nvarchar (Unicode) columns?

IVe read a lot about this. Still some questions : Im not talking about case sensitive here... If I have a char (ש for example) and he is stored in nvarchar - which can hold anything , Why would I need collation here ? If I'm "FaceBook" and i…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
17
votes
1 answer

Converting ntext to nvcharmax(max) - Getting around size limitation

I'm trying to change an existing SQL NText column to nvcharmax(max), and encountering an error on the size limit. There's a large amount of existing data, some of which is more than the 8k limit, I believe. We're looking to convert this, so that the…
Overflew
  • 7,872
  • 10
  • 45
  • 65
17
votes
3 answers

How to convert TIMESTAMP values to VARCHAR in T-SQL as SSMS does?

I am trying to convert a TIMESTAMP field in a table to a string so that it can be printed or executed as part of dynamic SQL. SSMS is able to do it, so there must be a built-in method to do it. However, I can't get it to work using T-SQL. The…
Neo
  • 4,145
  • 6
  • 53
  • 76
17
votes
3 answers

For Nvarchar(Max) I am only getting 4000 characters in TSQL?

This is for SS 2005. Why I am i only getting 4000 characters and not 8000? It truncates the string @SQL1 at 4000. ALTER PROCEDURE sp_AlloctionReport( @where NVARCHAR(1000), @alldate NVARCHAR(200), @alldateprevweek NVARCHAR(200)) AS …
Malcolm
  • 12,524
  • 28
  • 89
  • 125
16
votes
2 answers

Nvarchar and text are incompatible in the add operator

With SQL Server 2008, I'd like to add a variable (@wfID) into a text, like below: DECLARE @wfID uniqueidentifier SET @wfID = NEWID() '
Petty
  • 163
  • 1
  • 1
  • 4
16
votes
5 answers

How can Hibernate map the SQL data-type nvarchar(max)?

I have a column in my SQL-2005 database that used to be a varchar(max), but it has been changed to an nvarchar(max). Now I need to update my hibernate mapping file to reflect the change, and this is what it used to be:
ampersandre
  • 3,156
  • 3
  • 29
  • 37
15
votes
3 answers

Syntax for linq query to List

I am trying to do something like this... public static List GetAttachmentKeyList() { DataClassesDataContext dc = new DataClassesDataContext(); List list = from a in dc.Attachments select…
MalamuteMan
  • 151
  • 1
  • 1
  • 4
15
votes
2 answers

Should I be using JDBC getNString() instead of getString()?

We are building a Java application backed by an Oracle database that we access using JDBC (drivers ojdbc6.jar and orai18n.jar). The database schema stores text columns primarily using the NVARCHAR2 data type. The JDBC documentation for the JDBC…
Gnat
  • 2,861
  • 1
  • 21
  • 30
15
votes
3 answers

Sql Server - Index on nvarchar field

What is the good approach to keep a nvarchar field unique. I have a field which is storing URLs of MP3 files. The URL length can be anything from 10 characters to 4000. I tried to create an index and it says it cannot create the index as the total…
Parminder
  • 3,088
  • 6
  • 37
  • 61
15
votes
2 answers

nvarchar concatenation / index / nvarchar(max) inexplicable behavior

I today ran into a really weird problem in SQL Server (both 2008R2 and 2012). I'm trying to build up a string using concatenation in combination with a select statement. I have found workarounds, but I would really like to understand what's going on…
14
votes
3 answers

Converting Varchar to NVarchar?

I know when converting from nvarchar to varchar, some data will be lost/changed. However, are there any risks of data changing when converting a varchar data type to an nvarchar?
Curtis
  • 101,612
  • 66
  • 270
  • 352
14
votes
2 answers

Convert nvarchar to int in order to join SQL tables in a view

I want to create a view which will display the info from two tables joined by different type fields. The one field is nvarchar and the other one is int. I know i need to convert one type in the other but don't know how to do it. Any help would be…
Charalampos Afionis
  • 193
  • 1
  • 1
  • 11
14
votes
4 answers

Mapping to varchar and nvarchar in hibernate

If there are 2 columns in database, eg. code varchar(3) name nvarchar(50) How to tell hibernate to pass varchar for searching by code? In the hibernate mappings string is mapped to nvarchar and it produces queries like: Select code, name From table…
Niikola
  • 1,452
  • 1
  • 10
  • 12
13
votes
4 answers

Convert nvarchar to bigint in Sql server 2008

I want insert all rows of a table into another table, and I also want convert a nvarchar field into bigint, but when I use convert(bigint, col1) SQL Server shows an error: Error converting data type nvarchar to bigint How can I fix this problem?
Hossein Moradinia
  • 6,116
  • 14
  • 59
  • 85
1
2
3
32 33