Re: is this bad?

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 11/03/04


Date: Wed, 03 Nov 2004 23:03:45 +0100

On Wed, 3 Nov 2004 07:48:08 -0500, djc wrote:

>I am VERY new to stored procedure so I am making 3 assumptions from your
>example below. Please let me know if I'm correct.
>
>1) the ';' character must mark the end of a statement. So this makes the
>query sort by the first column then end the statement.

Hi djc,

This is incorrect. Previous versions of SQL Server choked on a ; at the
end of a statement. Newer versions do accept this, but it's still
optional. You could remove all ';' marks from any SQL script and SQL
Server will still happily execute it.

I only included the semicolons because you did - to make the code easier
to understand for you.

>2) the second statement deletes my table (yikes!)

Correct. Note that a DROP DATABASE statement would also have fit in the
varchar(50) positions available!!

>3) the '--' character must mark the beginning of a comment... which comments
>out any remaining code in the stored procedure.

Yep. That's to prevent errors. (If the rest of the code yields a syntax
error, nothing would get executed and your table would survive the
experiment).

>wow. thats way too easy, if I'm correct.

It is. That's why I posted my warning.

In case you haven't done so yet, go and read the information at Erland's
page NOW! --> http://www.sommarskog.se/dynamic_sql.html

Best, Hugo

-- 
(Remove _NO_ and _SPAM_ to get my e-mail address)


Relevant Pages

  • Re: select constant.field >> 10g float and double indicator
    ... > Mark C. Stock wrote: ... > I guess it uses some formatter which marks f as float. ... as BINARY_FLOAT and BINARY_DOUBLE data types in the 10g SQL Reference) ... instead of your original alias (of common usage but questionable etymology ...
    (comp.databases.oracle.misc)
  • Re: Trigger & Sequence ++ show errors for triggers
    ... Mark C. Stock wrote: ... :> that SHOW ERRORS does not work on trigger compilation errors ... SQL> CREATE OR REPLACE TRIGGER statement_level ...
    (comp.databases.oracle.server)
  • Re: DataReader Seek
    ... and syntax-wise you are right on the mark. ... problem with CF sp3 and SQL CE 2.0, so I'd really like to look into this in detail. ... Darren Shaffer ...
    (microsoft.public.sqlserver.ce)
  • pop-up form to filter report
    ... Dim strSQL As String, intCounter As Integer ... 'Build SQL String ... >I meant to remove the question mark: ... when writing sql code use double quotes ...
    (microsoft.public.access.reports)

Quantcast