使用连接到 SQL Server 2012 的 SQL Developer 时如何转义“&”符号

How to escape the “&” symbol when using SQL Developer connected to the SQL Server 2012

这是 senerio,我使用 Oralce SQl Developer(4.1.3) 连接到 SQL 服务器数据库 (2012)。这是我计划的 sql 语句执行。

    select   FORMAT(createDate,'yyyyMMdd') AS date,
         SUM(bb_cnt)                   AS 'Broadband Service',
         SUM(tel_cnt)                  AS 'Telephone Service',
         SUM(bb_tel_cnt)               AS 'Broadband & Telephone Service',
from    (select createDate,
                CASE WHEN ServicePlan LIKE '%Broadband Service%'              then 1 else 0 end AS bb_cnt,
                CASE WHEN ServicePlan LIKE 'Telephone Service%' OR ServicePlan LIKE '%, Telephone Service%' then 1 else 0 end AS tel_cnt,
                CASE WHEN ServicePlan LIKE '%Broadband & Telephone Service%' then 1 else 0 end AS bb_tel_cnt,
         from   EFormRegisterationData
        ) a
group by FORMAT(createDate,'yyyyMMdd') order by 1;

问题是我似乎无法让 SQL 开发人员将 & 识别为文字符号。我试过很多方法来逃避它,但它总是认为它是一个变量,我 google 这个问题并发现这个有用 link, SQL Developer, SQL Server and the ampersand,在这篇文章中,SQL 开发团队在您的 SQL 服务器查询之前提到了解决方法。 关闭定义; ",我试过了,但是 SQL 开发人员告诉它有语法错误,我很茫然,任何建议将不胜感激,谢谢。

plus: 完全相同 sql 在使用连接到 SQL Server 2012 的 DataGrip 时工作正常,太奇怪了,所以我认为问题出在客户端软件上,而不是 sql 语句本身。

尝试分解它。我在我的手机上,所以无法测试其他解决方案。

ServicePlan LIKE 'Broadband%' AND ServicePlan LIKE '%Telephone Service' THEN ...

http://rextester.com/ZFWCG68878