Re: If statement in subqueries
From: Keith Kratochvil (sqlguy.back2u_at_comcast.net)
Date: 12/01/04
- Next message: SangHunJung: "Select statement doesn't use index that I created"
- Previous message: Brian Moran: "Re: tempdb grows to 8G suddenly"
- In reply to: Chris Kennedy: "Re: If statement in subqueries"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 1 Dec 2004 08:26:49 -0600
So, have you reconsidered the use of TOP 100 PERCENT?
Three of us recommended that it be removed.
Have you tried re-writing the T-SQL to use a JOIN (as David and I
suggested)? Do you still get the same results? Are the results returned
faster?
-- Keith "Chris Kennedy" <chrisknospam@cybase.co.uk> wrote in message news:uAERdS41EHA.1404@TK2MSFTNGP11.phx.gbl... > Yes it's from Enterprise Manager. I am a programmer rather than a database > expert and just find I forget the syntax as I'll only do one once > everyweek/couple of days. I do know what you mean though about how some of > the joins it generates aren't very good. > > > "Sue Hoegemeier" <Sue_H@nomail.please> wrote in message > news:kbhpq0l4mc1l87q5mfiu87k0h8iv0ltrj0@4ax.com... > > Every time I've seen that used, its from people using > > Enterprise Manager and one of the builders to do their > > queries. I hate those queries. Some of the joins it > > generates are the most obnoxious things to look at, the > > parens are all over the place. I've seen them be nothing > > more than ugly messes. > > > > -Sue > > > > On Tue, 30 Nov 2004 11:26:37 -0500, "Aaron [SQL Server MVP]" > > <ten.xoc@dnartreb.noraa> wrote: > > > > >> SELECT TOP 100 PERCENT Surname, Forename, > > > > > >Why are you using TOP 100 PERCENT? > > > > > >> CASE > > >> WHEN tblNames.Surname='smith' THEN 0 > > >> else(SELECT Rank FROM dbo.tblKeynames WHERE (KeyName = Surname)) > > > > > >How are you limiting this to one row? Does tblKeynames have both a > Keyname > > >and a Surname column? If so, how do you expect the result from the > subquery > > >to have any possible relationship with the parent query? > > > > > >I suggest you post table schema, sample data, and desired results (for a > > >useful example; I doubt that leaving out any 'Smith' family is the actual > > >business requirement). > > > >
- Next message: SangHunJung: "Select statement doesn't use index that I created"
- Previous message: Brian Moran: "Re: tempdb grows to 8G suddenly"
- In reply to: Chris Kennedy: "Re: If statement in subqueries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|