将单引号替换为字符串中的双引号 [英] Replace Single Quote to Double quotes in a String

查看:181
本文介绍了将单引号替换为字符串中的双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我在SQL Server 2012的传入字符串中将单引号转换为双引号时遇到困难。目标字段是一个NVARCHAR字段,传入的字符串具有外来字符,其间有一些单引号。我需要将所有单引号更改为双引号,以便将它们加载到SQL Server中。有人可以帮我解决这个问题吗?我尝试了一些网上找到的方法,但没有运气。


提前致谢,

Selva。

Hello There,

I''m stuck with converting a single quote to double quotes in an incoming string in the SQL Server 2012. The target field is an NVARCHAR field and the incoming string has foreign characters with some single quotes in between. I need to get all the single quote''s changed to double quotes in order to load them in the SQL Server as it is. Can someone help me with this issue? I have tried some ways found online, but no luck at all.

Thanks in advance,
Selva.

推荐答案

到目前为止你尝试过哪些代码?
What code have you tried so far?


Hello Rabbit,


感谢您的回复,


选择替换(N''РВАТ''ЕЛЬРЫЧА''ЖКОВЫЙУ''РРВ-101.6'',Char(39),Char(34))Foreign_Chars;


选择替换(N''РВАТ''ЕЛЬРЫЧА''ЖКОВЫЙУ''РРВ-101.6'','''''''''''''''''''''''Foreign_Chars;


上面是两个查询,我试过了。
Hello Rabbit,

Thank you for getting back,

select replace(N''РВАТ''ЕЛЬ РЫЧА''ЖКОВЫЙ У''РРВ-101.6'', Char(39), Char(34)) Foreign_Chars;

select replace(N''РВАТ''ЕЛЬ РЫЧА''ЖКОВЫЙ У''РРВ-101.6'','''''''', '''''''') Foreign_Chars;

The above are two queries, I tried.


你不能在SQL中的静态字符串上执行此操作,它是'已经太晚了如果需要使用静态字符串,则必须手动进行替换。
You can''t do this on a static string in the SQL, it''s already too late. If you need to use a static string, you''ll have to do the replace manually.


这篇关于将单引号替换为字符串中的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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