October 27, 2004 at 1:34 pm
Hello everyone,
Can someone shed some light on the meaning of the ';' in transact-SQL for me? Always tought only GO can seperate batches and taht ';' was for Oracle only.
Best regards,
Carl
October 27, 2004 at 2:10 pm
GO and ; are specific language elements only understood by certain client programs.
SQL QA and ISQL/OSQL (as client applications) are written to understand GO and can be configured to use a line terminator.
ORACLE is...well just "goofy" I think is the best technical explanation. (shorter than describing the tighter coupling/dependencies of the client and server components).
October 28, 2004 at 10:34 am
Hello John,
can you be more explicit on the meaning of ';' in QA or ISQL/OSQL?
What is its purpose? An example?
thank's a lot,
Carl
October 29, 2004 at 2:34 pm
Like GO, the line terminator says take the prior string (ASCII text of your TRANSACT-SQL) and send it to the server. That's it. The server does all parsing, compiling, and executing of the SQL code.
(whereas in ORACLE it is not simple text being sent to the server.)
Oracle can only handle one statement at a time, while MSSQL can process an entire script (called a 'batch' in their lingo). Perhaps this is where your confusion lay: You think that, as in Oracle, a SELECT followed by an UPDATE and then a DELETE are one round trip when in actuality three round trips are made. In MSSQL you can send all three in one batch with one round trip (client->server->client).
Now if you choose you and say SELECT...; UPDATE...; DELETE...; and ISQL/W or OSQL will make three round trips (becaust by your ';' you've told it to separate these batches), just like in Oracle.
October 29, 2004 at 3:27 pm
The use of ; is prevalent in several database platforms to separate what we call batches in SQL Server lingo. It's a problem child because if I can insert a ; into a SQL query in the wrong place, I can execute code never intended with the security context of that process. Hence the reason the semi-colon is infamous in SQL Injection attacks (along with '-- and other techniques).
K. Brian Kelley
@kbriankelley
November 2, 2004 at 2:24 pm
Hlello John,
Not always like GO... try this one:
select @@version;
sp_who
Versus:
select @@version
go
sp_who
The first one gives an error:
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'sp_who'.
The second not...
Best regards,
Carl
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply