如何在SQL Server 2005中单引号连接字符串?

时间:2011-02-10 06:17:16

标签: sql-server sql-server-2005

语法错误BCHF_VOU_NUM +''+ BCHF_VOU_DTE

set @m_sql =  'Select distinct BCHF_VOU_NUM, BCHF_VOU_DTE, BCHF_E_AMT, NACD_DES, 
(BCHF_VOU_NUM +' '+ BCHF_VOU_DTE +' '+BCHF_E_AMT +' '+NACD_DES) as name,
dbo.E_DOC_NUM_2_CHEQUE_NO(BCHF_E_DOC_NUM) FROM ' + @ParaCoCode + '..BCH' + @ParaBatchNo  +   ' abc inner join v_AnalysisCode on BCHF_E_ANA_CDE1 = ANACode inner join  
Project_TR_TP_COM_Test.dbo.FlexAccount zz ON zz.CurrentAccountID = (Select 
CurrentAccountID from Batch where'

1 个答案:

答案 0 :(得分:5)

要在SQL中转义单引号,必须使用相同的字符两次。 ''将替换为连接字符串中的单引号。