In this case SQL 2000 produces the exact same execution plan for "SELECT 1" and "SELECT *" -

D:\>copy con: select1.sql set showplan_text on go if exists (select 1 from sysobjects where xtype = 'U' and name = 'jobs +') print 'exists' else print 'doesn''t exist' ^Z 1 file(s) copied. D:\>copy con: selectstar.sql set showplan_text on go if exists (select * from sysobjects where xtype = 'U' and name = 'jobs +') print 'exists' else print 'doesn''t exist' ^Z 1 file(s) copied. D:\>osql -dpubs -n -i selectstar.sql > selectstar.txt D:\>osql -dpubs -n -i select1.sql > select1.txt D:\>diff select1.txt selectstar.txt 3c3 < if exists (select 1 from sysobjects where xtype = 'U' and name = 'j +obs') --- > if exists (select * from sysobjects where xtype = 'U' and name = 'j +obs')

And while Win's SQL does compile without error, it may be a disaster in production. For example, this code (including the code you sanction) starts an infinite loop -

use pubs go create table Experimental_parameters (c char (1) primary key) insert into Experimental_parameters (c) values ('a') go create table another_table (c char (1) references Experimental_paramet +ers (c)) insert into another_table (c) values ('a') go WHILE (exists(select 1 from INFORMATION_SCHEMA.tables where table_name + = 'Experimental_parameters')) begin drop table Experimental_parameters -- fails end go print 'finished' -- never gets here

 


In reply to Re^4: T-SQL problem - Perl solution? by EdwardG
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.