【发布时间】:2016-02-29 13:12:24
【问题描述】:
我需要在 SQL 查询中使用 % 字符,然后将其传递到 Windows 批处理文件中。我的问题是没有考虑到这个字符。
towns=(12232, 12233)
for %%a in %towns% do (
"C:\Program Files\PostgreSQL\9.4\bin\pgsql2shp.exe" -h localhost -u thomas -P password thomas_db "SELECT * FROM schema.table WHERE code like '%%a%'"
)
我收到以下错误:
C:\batch> 正在初始化... 错误:无法确定表元数据
LIKE '%%a%' 被解释为LIKE '12232',应为LIKE '12232%'。
【问题讨论】:
-
like '%#%a%' escape '#'
标签: sql postgresql batch-file escaping