无法在sql中插入非英文字母 [英] Unable to insert nonenglish letter in sql

查看:80
本文介绍了无法在sql中插入非英文字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在ASP.NET中插入非英文字符,但它插入N ????

I am trying to insert non English character in SQL from ASP.NET, but it is inserting N????

CREATE PROCEDURE [dbo].[client_billing_address_sp_update] 
(
@in_type tinyint,
@vc_firstname_on_credit_card nvarchar(50) = ''
) 
AS
IF(@in_type = 1) 
BEGIN
INSERT INTO dbo.client_billing_address (vc_firstname_on_credit_card )
                VALUES('N'+@vc_firstname_on_credit_card)
END



为什么要插入N ????

如果我使用以下语句它可以工作:


Why it is inserting N????
If I use the following statement it works:

insert into item (item_name) values(N'अंगूर')

推荐答案

请查看类似的质量保证:

问题关于商店非英语字符 [ ^ ]

用于将非英文字符存储到SQL数据库的HTML / ASPX文本框 [ ^ ]

SQL插入多语言字符 [ ^ ]
Please have a look on similar QA:
Question about store Non-English chars[^]
HTML/ASPX textbox to store non-english characters to SQL database[^]
SQL Insert multilingual characters[^]


@vc_firstname_on_credit_card已经声明为nvarchar(50 )

所以你不需要写''N''+ @ vc_firstname_on_credit_card。只需使用:

@vc_firstname_on_credit_card is already declared as nvarchar(50)
so you don''t need to write ''N''+@vc_firstname_on_credit_card. Just use :
INSERT INTO dbo.client_billing_address (vc_firstname_on_credit_card )
                VALUES(@vc_firstname_on_credit_card)


在SQL Server中处理Unicode字符串常量时,必须在所有Unicode字符串前面加上大写字母N,如SQL Server联机丛书主题使用Unicode数据中所述。 N前缀代表SQL-92标准中的国家语言,必须为大写。如果您没有将Unicode字符串常量前缀为N,则SQL Server会在使用该字符串之前将其转换为当前数据库的非Unicode代码页。

- ------

NVarchar用于Unicode。如果您的数据库没有存储多语言数据,您可以继续使用Varchar。举个例子:N''abc''只是将你的字符串转换为unicode。
When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N, as documented in the SQL Server Books Online topic "Using Unicode Data". The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.
-------
NVarchar is used for Unicode. If your database is not storing multilingual Data you can keep using Varchar. As an example: N''abc'' simply converts your string to unicode.


这篇关于无法在sql中插入非英文字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆