如何在SQL WHERE子句中转义@符号?

时间:2014-04-15 13:43:22

标签: sql-server tsql escaping

我正试图在Excel中运行这样的东西:

SELECT currency_id, period_id, date, price_1, price_2

FROM Prices

WHERE scenario_id='1' AND period_from='04/14/2014' AND period_to='04/14/2014'
 AND date='04/14/2014' AND date_time='04/14/2014' price_type='r@periodic'

如何在SQL WHERE子句中转义@符号?

我得到“'price_type'错误附近的语法错误。

2 个答案:

答案 0 :(得分:2)

在date_time = '04 / 14/2014'和price_type ='r @ periodic'之间缺少AND运算符

答案 1 :(得分:0)

DECLARE @Bit VARCHAR(10) = 'r@period'
select REPLACE(@Bit,'@','')