问题描述
我正在使用参数化查询将我的经典 asp 转换为 .Net.我的问题是,在我的经典应用程序中,我会用 ascii 等效 '
I am converting my classic asp to .Net using parameterized queries. My problem is that in my classic apps I would replace the apostrophe with the ascii equivelent '
现在我想用真正的撇号替换数据库中的那个值.我不确定应该如何使用语法来做到这一点.我可以找到 '
但我不知道如何替换.以下是我试图消除该错误的简单更新.
Now I would like to replace that value in the database with a real apostrophe. I am not sure how the syntax should be to do this. I can find the '
but I am not sure how to replace. The following is the simple update I am trying to run that errors out.
更新 tblCustomer 集合Name = replace(Name, '''
, ''')
update tblCustomer setName = replace(Name, '''
, ''')
推荐答案
将撇号加倍以将其转义为字符串文字
Double up the apostrophe to escape it in a string literal
update tblCustomer set Name = replace(Name, ''', '''')
或者使用char
函数
update tblCustomer set Name = replace(Name, ''', CHAR(39))
这篇关于在sql数据库中用真正的撇号替换ascii撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!