簡體   English   中英

在SQL中插入單引號

[英]insert Single Quotation Marks in sql

我想在現有表的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'''

目前,您有3個在前,3個在后,按照戈登的回答,應該相反。

請參閱https://support.microsoft.com/en-us/kb/178070

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM