Click here to Skip to main content
12,505,389 members (76,055 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Happy new year... kind of... Pin
hoernchenmeister16-Jan-13 5:06
memberhoernchenmeister16-Jan-13 5:06 
GeneralRe: Happy new year... kind of... Pin
Matthys Terblanche16-Jan-13 21:08
memberMatthys Terblanche16-Jan-13 21:08 
GeneralRe: Happy new year... kind of... Pin
Gary Huck17-Jan-13 3:41
memberGary Huck17-Jan-13 3:41 
GeneralRe: Happy new year... kind of... Pin
Dave Kreskowiak17-Jan-13 5:26
mvpDave Kreskowiak17-Jan-13 5:26 
GeneralRe: Happy new year... kind of... Pin
Jörgen Andersson17-Jan-13 9:04
memberJörgen Andersson17-Jan-13 9:04 
GeneralRe: Happy new year... kind of... Pin
peterchen28-Jan-13 22:05
memberpeterchen28-Jan-13 22:05 
GeneralRe: Happy new year... kind of... Pin
hoernchenmeister28-Jan-13 22:49
memberhoernchenmeister28-Jan-13 22:49 
JokeRe: Happy new year... kind of... Pin
VUnreal8-Feb-13 10:27
memberVUnreal8-Feb-13 10:27 
GeneralJust got an error from VS2012 Pin
Brisingr Aerowing15-Jan-13 8:48
memberBrisingr Aerowing15-Jan-13 8:48 
GeneralGetting it wrong badly Pin
PIEBALDconsult9-Jan-13 14:12
memberPIEBALDconsult9-Jan-13 14:12 
GeneralRe: Getting it wrong badly Pin
Sentenryu10-Jan-13 6:31
memberSentenryu10-Jan-13 6:31 
GeneralRe: Getting it wrong badly Pin
PIEBALDconsult10-Jan-13 7:42
memberPIEBALDconsult10-Jan-13 7:42 
GeneralRe: Getting it wrong badly Pin
Sentenryu10-Jan-13 22:31
memberSentenryu10-Jan-13 22:31 
GeneralRe: Getting it wrong badly Pin
AspDotNetDev10-Jan-13 7:37
protectorAspDotNetDev10-Jan-13 7:37 
PIEBALDconsult wrote:
PATINDEX doesn't allow a parameter to tell it where to start so it always starts over from the beginning


Not only that, but the repeated use of stuff creates the same kind of inefficiency as you'd see in C# with the repeated use of "+" to concatenate strings. There is no StringBuilder in SQL, but there are workarounds. If you really want performance, this is what I'd do (describing rather than writing out, because I'm lazy)...

Create a while loop to visit each character in the string. Perform PATINDEX only on single characters (or two-character sequences, if you like). Output the strings to a local table variable then combine them using the FOR XML PATH technique (I haven't tried it myself, but it seems like it'd avoid repeat concatenations).

GeneralRe: Getting it wrong badly Pin
PIEBALDconsult10-Jan-13 7:52
memberPIEBALDconsult10-Jan-13 7:52 
GeneralRe: Getting it wrong badly Pin
AspDotNetDev10-Jan-13 8:11
protectorAspDotNetDev10-Jan-13 8:11 
GeneralFacepalm Moment Pin
Zac Greve7-Jan-13 8:47
memberZac Greve7-Jan-13 8:47 
GeneralRe: Facepalm Moment Pin
PJ Arends7-Jan-13 9:03
memberPJ Arends7-Jan-13 9:03 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 9:06
memberZac Greve7-Jan-13 9:06 
GeneralRe: Facepalm Moment Pin
peterchen7-Jan-13 10:03
memberpeterchen7-Jan-13 10:03 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 10:12
memberZac Greve7-Jan-13 10:12 
GeneralRe: Facepalm Moment Pin
Dave Kreskowiak7-Jan-13 9:15
mvpDave Kreskowiak7-Jan-13 9:15 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 9:30
memberZac Greve7-Jan-13 9:30 
GeneralRe: Facepalm Moment Pin
BobJanova7-Jan-13 23:29
memberBobJanova7-Jan-13 23:29 
GeneralRe: Facepalm Moment Pin
PIEBALDconsult7-Jan-13 9:17
memberPIEBALDconsult7-Jan-13 9:17 
GeneralRe: Facepalm Moment Pin
lewax007-Jan-13 10:52
memberlewax007-Jan-13 10:52 
GeneralRe: Facepalm Moment Pin
Jörgen Andersson7-Jan-13 10:05
memberJörgen Andersson7-Jan-13 10:05 
GeneralRe: Facepalm Moment Pin
Pete O'Hanlon7-Jan-13 10:17
protectorPete O'Hanlon7-Jan-13 10:17 
GeneralRe: Facepalm Moment Pin
Zac Greve7-Jan-13 10:20
memberZac Greve7-Jan-13 10:20 
GeneralRe: Facepalm Moment Pin
Rick Sparks7-Jan-13 14:17
memberRick Sparks7-Jan-13 14:17 
GeneralMessage Other user using CodeProject Pin
Suvabrata Roy26-Dec-12 1:59
memberSuvabrata Roy26-Dec-12 1:59 
GeneralRe: Message Other user using CodeProject Pin
GeekforChrist26-Dec-12 2:21
memberGeekforChrist26-Dec-12 2:21 
GeneralRe: Message Other user using CodeProject Pin
Suvabrata Roy26-Dec-12 2:35
memberSuvabrata Roy26-Dec-12 2:35 
GeneralRe: Message Other user using CodeProject Pin
OriginalGriff26-Dec-12 3:40
mvpOriginalGriff26-Dec-12 3:40 
GeneralRe: Message Other user using CodeProject Pin
GeekforChrist26-Dec-12 7:45
memberGeekforChrist26-Dec-12 7:45 
GeneralRe: Message Other user using CodeProject Pin
OriginalGriff26-Dec-12 8:53
mvpOriginalGriff26-Dec-12 8:53 
GeneralRe: Message Other user using CodeProject Pin
GeekforChrist26-Dec-12 9:09
memberGeekforChrist26-Dec-12 9:09 
GeneralRe: Message Other user using CodeProject Pin
April Fans26-Dec-12 16:51
memberApril Fans26-Dec-12 16:51 
GeneralRe: Message Other user using CodeProject Pin
Suvabrata Roy26-Dec-12 19:10
memberSuvabrata Roy26-Dec-12 19:10 
GeneralRe: Message Other user using CodeProject Pin
GeekforChrist27-Dec-12 2:33
memberGeekforChrist27-Dec-12 2:33 
GeneralRe: Message Other user using CodeProject Pin
Suvabrata Roy27-Dec-12 20:42
memberSuvabrata Roy27-Dec-12 20:42 
GeneralRe: Message Other user using CodeProject Pin
OriginalGriff27-Dec-12 22:00
mvpOriginalGriff27-Dec-12 22:00 
GeneralRe: Message Other user using CodeProject Pin
Suvabrata Roy27-Dec-12 22:13
memberSuvabrata Roy27-Dec-12 22:13 
GeneralRe: Message Other user using CodeProject Pin
OriginalGriff27-Dec-12 22:23
mvpOriginalGriff27-Dec-12 22:23 
GeneralRe: Message Other user using CodeProject Pin
Suvabrata Roy27-Dec-12 23:22
memberSuvabrata Roy27-Dec-12 23:22 
GeneralRe: Message Other user using CodeProject Pin
Jan Steyn9-Jan-13 21:48
memberJan Steyn9-Jan-13 21:48 
GeneralRe: Message Other user using CodeProject Pin
OriginalGriff9-Jan-13 22:06
mvpOriginalGriff9-Jan-13 22:06 
GeneralRe: Message Other user using CodeProject Pin
ProgramFOX26-Dec-12 3:46
memberProgramFOX26-Dec-12 3:46 
GeneralMake the font red! No, black! Can we do both? Pin
AnalogNerd20-Dec-12 8:51
memberAnalogNerd20-Dec-12 8:51 
GeneralRe: Make the font red! No, black! Can we do both? Pin
Rob Grainger20-Dec-12 9:21
memberRob Grainger20-Dec-12 9:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.160927.1 | Last Updated 27 Sep 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid