如何使用'在sql server中使用db引擎查询添加数据[重复]

时间:2021-07-31 17:06:40

This question already has an answer here:

这个问题在这里已有答案:

Iam having an error when Iam trying to add a data in the SQL Server DB Engine Query, here is my code:

Iam尝试在SQL Server数据库引擎查询中添加数据时出错,这是我的代码:

INSERT INTO tbl_product(PartNumber, Brand, Description, UnitPrice, SellingPrice, UnitofMeasure, Quantity, CategoryId, IsActive) VALUES
('AK4182',   'ADR',  '2 ROWS TYPE Z CITY 99' MANUAL',1845,2255,'PCS',0, 1,  0);

the error is because I have a ' in my description value "2 ROWS TYPE Z CITY 99' MANUAL.

错误是因为我有'在我的描述值'2 ROWS TYPE Z CITY 99'手册。

How can I add a this even with '?

我怎么能添加这个甚至'?

Thanks,
NicoTing

1 个解决方案

#1


0  

You need to escape it with an extra single quote('). For example:

你需要使用额外的单引号(')来逃避它。例如:

SELECT '2 ROWS TYPE Z CITY 99'' MANUAL':

#1


0  

You need to escape it with an extra single quote('). For example:

你需要使用额外的单引号(')来逃避它。例如:

SELECT '2 ROWS TYPE Z CITY 99'' MANUAL':