无法按原样插入值 - 需要回答任何数据库 - Oracle、Sql Server、MySql 等 [英] Cannot insert value as is - need answer for any DB - Oracle, Sql Server, MySql etc
问题描述
虽然这是一个SQL服务器的问题,但它适用于所有人.因此,也欢迎非 SQL 服务器答案.
Although this is a SQL server question, but it applies to all. So, non SQL server answers are also welcome.
我正在尝试创建一个表并向其中输入垃圾值,如下所示.SQL Server 从中删除所有垃圾字符并仅插入英文字符.如何让它允许我插入垃圾字符.它需要在这里测试一些代码 - 修剪字符串中的空格 - LTRIM RTRIM not工作
I am trying to create a table and enter junk values into it as shown below. SQL server removes all the junk characters from it and inserts only english characters. How do I make it allow me to insert junk characters. Its needed to test some code here - Trim spaces in string - LTRIM RTRIM not working
CREATE TABLE [dbo].[Junk](
[JunkHex] [varchar](50) NULL
) ON [PRIMARY]
GO
GO
INSERT [dbo].[Junk] ([JunkHex]) VALUES ('Stringğ ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES ('withħ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES ('įņvalidđ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES ('charactersŝ')
推荐答案
尝试使用国家字符集创建字段并将常量定义为宽字符串:
Try creating the field with the national character set and defining the constants as wide strings:
CREATE TABLE [dbo].[Junk](
[JunkHex] nvarchar(50) NULL
) ON [PRIMARY]
GO
GO
INSERT [dbo].[Junk] ([JunkHex]) VALUES (N'Stringğ ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES (N'withħ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES (N'įņvalidđ')
INSERT [dbo].[Junk] ([JunkHex]) VALUES (N'charactersŝ')
您可以在 SQL Fiddle 上看到这项工作.
You can see this work on SQL Fiddle.
这篇关于无法按原样插入值 - 需要回答任何数据库 - Oracle、Sql Server、MySql 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!