Skip to Content.
Sympa Menu

freetds - Re: [freetds] Please help: "create view" failing

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <james.k.lowden AT alliancebernstein.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Please help: "create view" failing
  • Date: Thu, 9 Nov 2006 13:06:47 -0500

> From: Paul Rensing
> Sent: Thursday, November 09, 2006 11:16 AM
>
> 1> create view TEST_VIEW as select * from otherdb..SOME_TABLE;
> 2> go
> then I get the error:
> Msg 170, Level 15, State 1, Server XXX, Line 1
> Line 1: Incorrect syntax near ';'.
...
> Can someone please explain why the semi-colon is breaking the SQL? I
> would like to understand this so I can try to work around the problem
> (the ";" is inserted automatically in Mono).

You already got correct answers, but in case you're going to talk to the
Mono folks, I thought I'd try to be a little more precise.

The ';' is not valid in T-SQL. It is just as though you tried this:

1> if( 1=0 ) { print 'hi' }
2> go
Msg 170, Level 15, State 1, Server AC2KAMA0848, Line 1
Line 1: Incorrect syntax near '{'.

Some tools e.g. tsql notice the ';' and treat it as a "batch separator".
It tells the tool "send everything up to here to the server". Other
tools may simply ignore it.

If you look at the SQL tsql sends to the server, you'll see the
semicolon is not present. The *server* doesn't regard the semicolon as
anything special. If the server does see the semicolon, it had better
not be where there ought to be valid syntax. Else you get an "invalid
syntax" error.

T-SQL in this way does not conform to the SQL-92 standard. But millions
of lines of T-SQL already exist, and to require them all to have
semicolons would make for a lot of unhappy customers. (And btw their
mere existence is a strong argument that semicolons are unnecessary in
SQL.)

HTH.

--jkl

-----------------------------------------
The information contained in this transmission may be privileged and
confidential 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. If you, as the intended
recipient
of this message, the purpose of which is to inform and update our clients,
prospects
and consultants of developments relating to our services and products, would
not
like to receive further e-mail correspondence from the sender, please "reply"
to the
sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New
York,
NY 10105.




Archive powered by MHonArc 2.6.24.

Top of Page