Click here to Skip to main content

Welcome to the Lounge

   

For lazing about and discussing anything in a software developer's life that takes your fancy.
The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct and please don't post ads.

Technical discussions are welcome, but if you need specific help please use the programming forums.


 
GeneralRe: Admit it NOW PinprofessionalS Houghtelin20-Jun-14 6:41 
GeneralRe: Admit it NOW PinmemberHomerTheGreat20-Jun-14 7:44 
AnswerRe: Admit it NOW PinprofessionalDan Colasanti20-Jun-14 8:05 
JokeRe: Admit it NOW Pinmemberjeron120-Jun-14 8:31 
GeneralXCode question PinmemberMikeGledhill20-Jun-14 4:45 
GeneralRe: XCode question Pinmember d@nish 20-Jun-14 4:54 
GeneralRe: XCode question PinmvpNish Sivakumar20-Jun-14 5:15 
GeneralRe: XCode question PinmemberIan Shlasko20-Jun-14 5:18 
GeneralRe: XCode question PinmemberFrank Alviani20-Jun-14 5:49 
GeneralRe: XCode question PinmemberPIEBALDconsult20-Jun-14 6:21 
GeneralRe: XCode question PinmemberNemanja Trifunovic20-Jun-14 9:24 
GeneralRe: XCode question PinmemberDennis E White20-Jun-14 10:43 
GeneralRe: XCode question PinmemberDennis E White20-Jun-14 10:48 
GeneralDiscoveries [modified] PinmemberJohn Simmons / outlaw programmer20-Jun-14 4:08 
New job, perusing one of the dozens of databases we use on a daily basis. I found:
 
0) All of the views in at least one of our databases includes this:
 
SELECT TOP(100) PERCENT
...
ORDER BY...
 
Evidently, the first line enables you to trick SqlServer 2008 (and earlier) into allowing the ORDER BY clause in a view. Of course, newer versions of SQL Server ignore both clauses, and IMHO doing ORDER BY in a view is kinda pointless anyway
 
1) I encountered a view that has 519 OR clauses that evaluate the value of 20 columns. When run in its original form, it took 11 seconds to execute and returns 2900 rows. I modified it to declare a varchar variable and then called CHARINDEX for each column one time, and execution time is now < 1 second.
 
2) I encountered another view like the one above where execution time was 4 seconds, and using the same technique, I reduced it to < 1 second.
 
3) Formatting of the SQL I've seen so far is, well, abysmal - and that's me being nice .
 
I consider my SQL skills to be slightly above the beginner level, but jeeze...
 
EDIT =======================
 
I'm surprised nobody has yet pointed out that you can't declare local vars in views (ask me how I know). :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013


modified 20-Jun-14 10:55am.

GeneralRe: Discoveries PinmemberHomerTheGreat20-Jun-14 4:14 
GeneralRe: Discoveries PinmemberPIEBALDconsult20-Jun-14 4:16 
GeneralRe: Discoveries PinmemberPualee20-Jun-14 4:20 
GeneralRe: Discoveries PinprofessionalRichard Deeming20-Jun-14 4:32 
GeneralRe: Discoveries PinmemberJohn Simmons / outlaw programmer20-Jun-14 4:53 
GeneralRe: Discoveries PinmemberTim Carmichael20-Jun-14 5:41 
GeneralRe: Discoveries PinmemberDan Neely20-Jun-14 5:41 
GeneralRe: Discoveries Pinmembernewton.saber20-Jun-14 5:52 
GeneralRe: Discoveries PinprofessionalSander Rossel20-Jun-14 7:40 
GeneralI didn't realize this law was necessary PinmemberKschuler20-Jun-14 3:44 
GeneralRe: I didn't realize this law was necessary PinprotectorOriginalGriff20-Jun-14 4:11 
GeneralRe: I didn't realize this law was necessary PinmemberPualee20-Jun-14 4:23 
GeneralRe: I didn't realize this law was necessary PinmemberPapaCraft20-Jun-14 4:38 
GeneralRe: I didn't realize this law was necessary Pinmemberdeflinek20-Jun-14 6:46 
GeneralRe: I didn't realize this law was necessary PinmemberBergholt Stuttley Johnson20-Jun-14 4:55 
GeneralRe: I didn't realize this law was necessary PinprofessionalMaarten Kools20-Jun-14 5:14 
GeneralRe: I didn't realize this law was necessary PinmemberIan Shlasko20-Jun-14 5:14 
GeneralRe: I didn't realize this law was necessary PinmemberJimmyRopes20-Jun-14 6:17 
GeneralRe: I didn't realize this law was necessary Pinmemberbling20-Jun-14 6:25 
GeneralRe: I didn't realize this law was necessary PinmemberPIEBALDconsult20-Jun-14 7:49 
GeneralRe: I didn't realize this law was necessary PinmemberIan Shlasko20-Jun-14 8:17 
GeneralRe: I didn't realize this law was necessary PinprotectorOriginalGriff20-Jun-14 8:44 
GeneralRe: I didn't realize this law was necessary PinmemberPIEBALDconsult20-Jun-14 14:13 
GeneralRe: I didn't realize this law was necessary PinmemberJimmyRopes20-Jun-14 18:18 
GeneralRe: I didn't realize this law was necessary PinmemberHomerTheGreat20-Jun-14 9:33 
JokeRe: I didn't realize this law was necessary PinmemberPapaCraft20-Jun-14 12:58 
GeneralWell, I have one question today... PinprofessionalglennPattonWork20-Jun-14 3:42 
GeneralRe: Well, I have one question today... PinmemberWiganLatics20-Jun-14 3:48 
GeneralRe: Well, I have one question today... PinprofessionalglennPattonWork20-Jun-14 4:01 
GeneralRe: Well, I have one question today... PinprotectorOriginalGriff20-Jun-14 4:07 
GeneralRe: Well, I have one question today... PinmemberWiganLatics20-Jun-14 4:15 
GeneralHappy Birthday, Nish! PinmemberRoger Wright20-Jun-14 3:37 
GeneralRe: Happy Birthday, Nish! PinmemberDinesh.V.Kumar20-Jun-14 3:41 
GeneralRe: Happy Birthday, Nish! PinmvpNish Sivakumar20-Jun-14 3:52 
GeneralRe: Happy Birthday, Nish! PinprotectorMarco Bertschi20-Jun-14 4:28 
GeneralRe: Happy Birthday, Nish! PinmvpNish Sivakumar20-Jun-14 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 18 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid