Good point on the execution plans EdwardG. This example may be trivial enough that SELECT * is not better than SELECT 1. I should have stated more clearly that it is good practice to use SELECT * in an EXISTS because it can give performance improvements. Your mileage may vary.

There is no inherent problem with using the WHILE clause just as I posted it. I certainly didn't sanction the code you posted but it is a good example and well worth noting. You never want to get stuck in an infinite loop. Error checking should also always be done.

DROP TABLE Experimental_parameters IF @@ERROR <> 0 BEGIN --DO SOMETHING HERE (i.e. RAISERROR & RETURN) END
Update: I just read the OP. I was replying to Re^2: T-SQL problem - Perl solution? which didn't indicate a temp table or code inside the WHILE. My sanctioned code could yield the behavior EdwardG posted based on the OP. The OP had
if (SELECT COUNT(*) FROM #Experimental_parameters) <> 0 begin DROP TAB +LE Experimental_parameters end
Error hanling code needs to be used inside the WHILE.

Good call EdwardG. Thanks

In reply to Re^5: T-SQL problem - Perl solution? by monktim
in thread T-SQL problem - Perl solution? by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.