【发布时间】:2015-10-07 06:08:58
【问题描述】:
- SQL 客户端:Ubuntu 14.04LTS
- DB 服务器:MS SQL server 2005,通过 odbc 和 Freetds 访问。适用于我的其他 MS SQL 2005 服务器。
- isql 2.2.14
- Freetds 0.91
- 文本编辑器:Windows 7 的 Notepad++ 6.5.5 正在通过 Samba 共享在 Ubuntu 上编辑我的 .sql 文件。
- 不,我无法升级任何东西,我只能坚持现有的。
这让我很难过。我从 i-net Clear Reports 复制并粘贴了一条 SQL 语句,并将其粘贴到 Windows 编辑器中,该编辑器正在编辑一个 Ubuntu .sql 文件,它只是一个文本文件。我已经通过 isql 和 Perl 毫无问题地连接到另一台 MS SQL 2005 服务器。所以我遇到了一个包含大约 10 个连接的大型 SQL 语句的问题,并将语句简化为这些多行:
SELECT PKG.SO_ID
FROM
PACKAGES AS PKG
WHERE
PKG.tracking_no = '640038823199'
;
此文件由多行以 unix 行结尾组成。我的 isql 命令是:cat test1.sql | isql dsnname 'domain\username' password -v -b。
我将 -b 用于批处理模式,因为我通过文件将输入发送到 isql。 错误立即从第一行开始,但我仔细检查了语法,对于 SQL Server 2005,“AS”在“PACKAGES AS PKG”中是可选的。
[37000][unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared.
[37000][unixODBC][FreeTDS][SQL Server]The multi-part identifier "PKG.SO_ID" could not be bound.
[ISQL]ERROR: Could not SQLExecute
[37000][unixODBC][FreeTDS][SQL Server]Incorrect syntax near the keyword 'FROM'.
[37000][unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared.
[ISQL]ERROR: Could not SQLExecute
[37000][unixODBC][FreeTDS][SQL Server]Incorrect syntax near the keyword 'AS'.
[37000][unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared.
[ISQL]ERROR: Could not SQLExecute
[37000][unixODBC][FreeTDS][SQL Server]Incorrect syntax near the keyword 'WHERE'.
[37000][unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared.
[ISQL]ERROR: Could not SQLExecute
[37000][unixODBC][FreeTDS][SQL Server]Incorrect syntax near '='.
[37000][unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared.
[ISQL]ERROR: Could not SQLExecute
- 这到底是怎么回事?
- 是否 isql 或 MS SQL 的 test1.sql 文件中的选项卡有问题?在
PKG.tracking_no之前有一个标签。 - 我假设 .sql 文件只是一个包含 SQL 语句的文本文件,跨越一行或多行。
谢谢。
【问题讨论】:
标签: perl sql-server-2005 odbc freetds