在sql中插入单引号

在sql中插入单引号,sql,sql-server-2008,sql-update,sql-insert,Sql,Sql Server 2008,Sql Update,Sql Insert,我想在现有表的AlertSQL列中插入“exec e_Report.dbo.FTX_FA_Aging_Report_sp‘FACloedAgingReport’” 我的更新脚本将如何运行 我的更新脚本如下所示: update dbo.F_ALERT set AlertSQL= 'exec e_Report.dbo.FTX_FA_Aging_Report_sp '''FACloedAgingReport'' where AlertID=9330 有些人认为这并没有给我预

我想在现有表的AlertSQL列中插入“exec e_Report.dbo.FTX_FA_Aging_Report_sp‘FACloedAgingReport’”

我的更新脚本将如何运行

我的更新脚本如下所示:

update dbo.F_ALERT
    set AlertSQL= 'exec e_Report.dbo.FTX_FA_Aging_Report_sp '''FACloedAgingReport''
        where AlertID=9330 
有些人认为这并没有给我预期的结果。
提前谢谢

你需要更多的报价和东西:

update dbo.F_ALERT
    set AlertSQL= 'exec e_Report.dbo.FTX_FA_Aging_Report_sp ''FACloedAgingReport'''
        where AlertID = 9330 ;
这有点让人困惑,但是
'''
是一个带单引号的字符串。两个单引号合在一起就是一个单引号。因此:

'exec e_Report.dbo.FTX_FA_Aging_Report_sp ''FACloedAgingReport'''
^ starts a string
------------------------------------------^ two quotes are single quote in the string
--------------------------------------------------------------^ two quotes are single quote in the string and then one more to end the string itself

检查您的报价定位。在带引号的字符串的两端需要一对单引号,以及整个查询的引号

'exec ee_Report.dbo.FTX_FA_Aging_Report_sp ''FACloedAgingReportSee'''
目前你有三个之前和两个之后,这应该是另一种方式,根据戈登的回答


请参见

这是用于哪个RDBMS的?请添加一个标记,以指定您使用的是
mysql
postgresql
sql server
oracle
db2
-还是其他完全相同的东西。@marc_s sql server 2008您在sql server 2008上试用过吗(就像问题被标记了一样)?回答时问题没有标记written@QuantumTiger如果insert语句是sql 2000,它将如何运行?会有所不同吗?这可能会有所帮助