[freetds] MSSQL syntax flavors
Lowden, James K
LowdenJK at bernstein.com
Thu Jul 3 12:25:40 EDT 2003
> From: Andrew Pimlott [mailto:andrew at pimlott.net]
> Sent: July 3, 2003 9:03 AM
>
> On Thu, Jul 03, 2003 at 08:30:00AM +0200, Michael Peppler wrote:
> >
> > Interesting - maybe the MSSQL query tool silently removes the
> > semi-colon.
>
> I doubt it's just that: The line above is part of a long statement,
> so the query tool would have to be parsing the whole statement.
> Plus, I found other discrepancies (since sending the message), for
> example with sqsh I get complaints of errors that the MSSQL tool
> ignores, like non-existent columns (in this respect, sqsh works
> better!). Also, I had to change "GO" to "go" in one place. It
> really seems like I'm using a whole (but subtly) different mode.
The differences you're describing are in the application, not the protocol.
If you are using TDS 7.0 with sqsh, then the server really can't distinguish
between sqsh and any Microsoft ODBC tool.
For instance, GO/go isn't sent to the server; it's processed by the tool and
serves as a terminator, separating batches of SQL:
$ isql -E -c foo
1> select 1; select 2
2> go
3> foo
-----------
1
(1 row affected)
go
-----------
2
(1 row affected)
Note Microsoft's isql uses TDS 4.2. It passes the semicolon to the server
(which ignores it), passes "go" as a column label for the second select
statement, and sends the batch on "foo".
How do I know the semicolon is passed? The same query works with tsql!
> > and sqsh will often interpret the
> > ; as meaning "go" - i.e. send the current SQL batch to the server).
>
> You're right that removing the semicolon makes everyone happy.
"man sqsh" is your friend here. sqsh has quite a lot of built-in semicolon
interpretation.
I think the moral of the story is that different tools are different. We
quite often get questions here along the lines of "it works in [tool] but
not in FreeTDS". Many times it turns out to be a flaw in FreeTDS, and
sometimes it's just an idiosyncrasy of [tool]. ;-)
--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions.
More information about the FreeTDS
mailing list