更新 SQL 数据但数据包含 ' 所以我收到错误 [英] Update SQL data but the data contains ' so I get errors
本文介绍了更新 SQL 数据但数据包含 ' 所以我收到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新 SQL 数据,但它包含 '
,因此出现错误.
I'm trying to update SQL data but it contains '
so I get errors.
SQL 语句如下所示:
The SQL statement looks like this:
UPDATE SystemConfiguration
SET HeaderScript = '<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],'
WHERE ID = 1
我尝试用 "
替换引号,但出现错误.我也尝试不使用引号,但也出现错误.
I tried to replace the quote with "
but I get error. I also tried without quote I get error as well.
任何建议.
推荐答案
您需要将单引号加倍以将它们转义:
You need to double the single quotes to escape them:
UPDATE SystemConfiguration
SET HeaderScript = '<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({''gtm.start'': new Date().getTime(),event:''gtm.js''});var f=d.getElementsByTagName(s)[0],'
WHERE ID = 1
这篇关于更新 SQL 数据但数据包含 ' 所以我收到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文