nvarchar

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

不打扰是莪最后的温柔 提交于 2019-12-05 01:32:19
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 ResultSet says that getNString() is particularly intended for use with the NCHAR, NVARCHAR etc. data types, but at the moment we are only using getString() . This seems to work fine, so I am wondering why I should use getNString() rather than getString() . Is getString() going to start failing if non-ASCII characters are entered, or is the Oracle JDBC

SQL Command to insert Chinese Letters

半世苍凉 提交于 2019-12-04 05:25:36
问题 I have a database with one column of the type nvarchar. If I write INSERT INTO table VALUES ("玄真") It shows ¿¿ in the table. What should I do? I'm using SQL Developer. 回答1: Use single quotes, rather than double quotes, to create a text literal and for a NVARCHAR2 / NCHAR text literal you need to prefix it with N SQL Fiddle Oracle 11g R2 Schema Setup : CREATE TABLE table_name ( value NVARCHAR2(20) ); INSERT INTO table_name VALUES (N'玄真'); Query 1 : SELECT * FROM table_name Results : | VALUE |

How to return an nvarchar(max) in a CLR UDF?

你离开我真会死。 提交于 2019-12-04 02:30:19
Assuming following definition: /// <summary> /// Replaces each occurrence of sPattern in sInput with sReplace. This is done /// with the CLR: /// new RegEx(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace). /// The result of the replacement is the return value. /// </summary> [SqlFunction(IsDeterministic = true)] public static SqlString FRegexReplace(string sInput, string sPattern, string sReplace) { return new Regex(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace); } Passing in a nvarchar(max) value for sInput with a length > 4000 will result in the value being truncated

Difference between NVARCHAR in Oracle and SQL Server?

孤者浪人 提交于 2019-12-03 09:36:30
问题 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 stackoverflow and want to confirm my findings. Oracle VARCHAR2 already supports unicode if the database character set is say AL32UTF8 (which is true for our case). SQLServer VARCHAR does not support unicode. SQLServer explicitly requires columns to be in

Sql Server - Index on nvarchar field

浪尽此生 提交于 2019-12-03 05:35:55
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 length exceeds 900 bytes. If the field is not indexed, it's going to be slow to search anything. I am using C#, ASP.net MVC for the front end. You could use CHECKSUM command and put index on column with checksum. --*** Add extra column to your table that will hold checksum ALTER TABLE Production.Product ADD cs_Pname AS CHECKSUM(Name); GO --*** Create

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

旧巷老猫 提交于 2019-12-03 04:54:21
问题 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 Server, NCHAR is stored as UTF-16LE and is the only way to reliably store non-ASCII characters, CHAR being a single-byte codepage only; In Oracle, NVARCHAR may be stored as UTF-16 or UTF-8 rather than a single-byte collation; But in MySQL, NVARCHAR

Difference between NVARCHAR in Oracle and SQL Server?

亡梦爱人 提交于 2019-12-03 00:17:11
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 stackoverflow and want to confirm my findings. Oracle VARCHAR2 already supports unicode if the database character set is say AL32UTF8 (which is true for our case). SQLServer VARCHAR does not support unicode. SQLServer explicitly requires columns to be in NCHAR/NVARCHAR type to store data in unicode (specifically in the 2 byte UCS-2 format).. Hence would it be

Weird SQL Server 2005 Collation difference between varchar() and nvarchar()

▼魔方 西西 提交于 2019-12-01 18:02:13
问题 Can someone please explain this: SELECT CASE WHEN CAST('iX' AS nvarchar(20)) > CAST('-X' AS nvarchar(20)) THEN 1 ELSE 0 END, CASE WHEN CAST('iX' AS varchar(20)) > CAST('-X' AS varchar(20)) THEN 1 ELSE 0 END Results: 0 1 SELECT CASE WHEN CAST('i' AS nvarchar(20)) > CAST('-' AS nvarchar(20)) THEN 1 ELSE 0 END, CASE WHEN CAST('i' AS varchar(20)) > CAST('-' AS varchar(20)) THEN 1 ELSE 0 END Results: 1 1 On the first query, the nvarchar() result is not what I'm expecting, and yet removing the X

Weird SQL Server 2005 Collation difference between varchar() and nvarchar()

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 17:52:35
Can someone please explain this: SELECT CASE WHEN CAST('iX' AS nvarchar(20)) > CAST('-X' AS nvarchar(20)) THEN 1 ELSE 0 END, CASE WHEN CAST('iX' AS varchar(20)) > CAST('-X' AS varchar(20)) THEN 1 ELSE 0 END Results: 0 1 SELECT CASE WHEN CAST('i' AS nvarchar(20)) > CAST('-' AS nvarchar(20)) THEN 1 ELSE 0 END, CASE WHEN CAST('i' AS varchar(20)) > CAST('-' AS varchar(20)) THEN 1 ELSE 0 END Results: 1 1 On the first query, the nvarchar() result is not what I'm expecting, and yet removing the X make the nvarchar() sort happen as expected. (My original queries used the '' and N'' literal syntax to

Conversion failed when converting the nvarchar value 'Internet Explorer 3 original' to data type int

天大地大妈咪最大 提交于 2019-12-01 11:34:42
In SQL Server 2008 (TSQL), I've created a stored procedure like this: CREATE PROCEDURE SP_1_10_2 AS declare @mostValuableBook nvarchar(255) SELECT @mostValuableBook = Name FROM books WHERE price = ( SELECT MAX(price) FROM books WHERE izd LIKE '%BHV%' ); return @mostValuableBook GO But, when I'm trying to execute it: declare @x nvarchar(255) EXECUTE @x = SP_1_10_2; SELECT 'The most expensive BHV book:', @x AS 'Name' GO I'm getting an error: Conversion failed when converting the nvarchar value 'Internet Explorer 3 original' to data type int. It seems like the problem is in the line EXECUTE @x =