如何更新SQL中的特殊字符? [英] How to update special characters in SQL?

查看:524
本文介绍了如何更新SQL中的特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我试图更新我的表行的查询,但它在Sql Server中给了我一些错误。有人帮我怎么做



我尝试了什么:



更新表格设置col ='它是'其中col ='它'

Below is the query where i am trying to update my table row but it's giving me some error In Sql Server.Can someone help me how to do this

What I have tried:

update table set col='It's' where col='It'

推荐答案

是的,我们可以帮到你。但是,为了将来参考,如果您需要帮助解决错误消息,步骤1是发布错误消息。有42,233,543可能的错误消息,所以它有助于给出确切的错误而不会让人猜测。



在这种情况下,错误非常简单。你在单词It's中有一个引号,因此,它打破了字符串。编译器认为你想要将col更新为It然后你有s并且它不知道这意味着什么。你需要用另一个撇号来逃避你的撇号。

Yes, we can help you. However, for future reference, if you want help solving an error message, step 1 is to post the error message. There are 42,233,543 possible error messages so it helps to give the exact error and not make people guess.

In this case, the error is very simple. You have a single quote in the word "It's", therefore, it is breaking the string. The compiler thinks you want to update the col to be "It" and then you have "'s" and it has no idea what that means. You need to escape your apostrophe with another apostrophe.
UPDATE table SET col='It''s' WHERE col='It'





错误信息会告诉你发生了什么。



And the error message would have told you what was going on.


这篇关于如何更新SQL中的特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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