刚开始以为是一个单引号,或者是一个双引号, 没想到是两个单引号,郁闷
例如下面
SET @SQLOne = ' INSERT INTO #ddlist(DDGuid,HBGUID,EnumDDLY,DDType,LYDH,DJBH,RQ,SJJE,WLFY,SumMoney,Audit,Auditor,AuditTime,Record,RecordTime) SELECT dbo.DD.Guid AS DDGuid, dbo.DD.HBGUID, (CASE dbo.DD.DDLY WHEN 0 THEN ' '系统网站' ' WHEN 1 THEN ' '淘宝网站' ' WHEN 2 THEN ' '其他' ' WHEN 3 THEN ' '淘宝分销' ' WHEN 4 THEN ' '拍拍网站' ' WHEN 5 THEN ' '京东商城' ' WHEN 6 THEN ' '当当网站' ' WHEN 7 THEN ' 'E链通' ' WHEN 8 THEN ' '商派网站' ' WHEN 9 THEN ' 'POS门店' ' WHEN 10 THEN ' '商派分销王' ' WHEN 11 THEN ' '一号店' ' WHEN 12 THEN ' '凡客商城' ' WHEN 13 THEN ' '品聚网站' ' WHEN 14 THEN ' '卓越亚马逊' ' WHEN 16 THEN ' '邮乐商城' ' WHEN 17 THEN ' '好乐买' ' WHEN 18 THEN ' 'QQ网购' ' WHEN 19 THEN ' 'QQ彩贝' ' WHEN 20 THEN ' '阿里巴巴' ' WHEN 21 THEN ' '优购' ' WHEN 22 THEN ' '新蛋网' ' WHEN 23 THEN ' '聚美优品' ' WHEN 24 THEN ' '商派易开店' ' WHEN 100 THEN ' '乐蜂网' ' WHEN 101 THEN ' 'ERPFX' ' END) AS EnumDDLY, ' '销售订单' ' AS DDType,LYDH,dbo.DD.DJBH,pt.SMRQ AS RQ,SJJE,WLFY,ISNULL(SJJE,0)+ISNULL(WLFY, 0)-ISNULL(RLJE,0) AS SumMoney, 0 AS Audit,null AS Auditor, NULL AS AuditTime,0 as Record, NULL AS RecordTime FROM dbo.DD LEFT OUTER JOIN dbo.DD_ShenHe AS SH WITH(NOLOCK) ON dbo.DD.GUID = SH.GUID LEFT OUTER JOIN dbo.DD_Delivery AS Dli WITH(NOLOCK) ON dd.GUID = Dli.GUID LEFT OUTER JOIN dbo.DD_Print AS pt WITH(NOLOCK) ON dd.GUID = pt.GUID WHERE ISNULL(Dli.FH, 0) = 1 AND ((dbo.DD.HBGUID IS NULL AND ISNULL(SH.ZF,0)= 0) OR (dbo.DD.HBGUID IS NOT NULL AND ISNULL(SH.ZF,0)=1 AND SH.ZFR = ' '系统合并' '))' EXEC (@SQLOne);