Click here to Skip to main content
15,993,717 members

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: Linux C PreProcessor: Who Knew? Pin
k50549-Jul-24 3:51
mvek50549-Jul-24 3:51 
GeneralRe: Linux C PreProcessor: Who Knew? Pin
raddevus9-Jul-24 4:51
mvaraddevus9-Jul-24 4:51 
GeneralDoes this scare anyone else? Pin
honey the codewitch4-Jul-24 0:44
mvahoney the codewitch4-Jul-24 0:44 
GeneralRe: Does this scare anyone else? Pin
Peter_in_27804-Jul-24 11:33
professionalPeter_in_27804-Jul-24 11:33 
GeneralRe: Does this scare anyone else? Pin
honey the codewitch4-Jul-24 11:35
mvahoney the codewitch4-Jul-24 11:35 
GeneralWhat the hell GCC, again Pin
k50542-Jul-24 11:32
mvek50542-Jul-24 11:32 
GeneralRe: What the hell GCC, again Pin
Brisingr Aerowing13-Aug-24 15:16
professionalBrisingr Aerowing13-Aug-24 15:16 
GeneralDynamic SQL Pin
Richard Andrew x6430-Jun-24 9:43
professionalRichard Andrew x6430-Jun-24 9:43 
Has anyone ever seen a DB stored procedure where the queries weren't written using SQL, but rather using string concatenation to build the queries, and then submitting the queries with the EXEC command?

I can't think of a more horrifically error-prone way of coding in T-SQL. But I see this from a prominent maker of Warehouse Management Systems.

The first time I ever saw that, I was taken aback because I couldn't understand why anyone would do that. But then I saw that it was done so that the queries could be written to target different databases, tables, and columns depending upon the values of local variables.

So even something as weird and wonderful as that has a use. I wonder if any other RDMS has a more elegant solution?

EDIT:

I realize that the queries could still be written using regular T-SQL, but in a more structured way. But I see that this strange practice waas done for the sake of simpler, straight-line code.
The difficult we do right away...
...the impossible takes slightly longer.


modified 30-Jun-24 16:00pm.

GeneralRe: Dynamic SQL Pin
raddevus30-Jun-24 12:47
mvaraddevus30-Jun-24 12:47 
GeneralRe: Dynamic SQL Pin
Richard Deeming30-Jun-24 21:36
mveRichard Deeming30-Jun-24 21:36 
GeneralRe: Dynamic SQL Pin
PIEBALDconsult30-Jun-24 17:50
mvePIEBALDconsult30-Jun-24 17:50 
GeneralRe: Dynamic SQL Pin
Shane010330-Jun-24 18:07
Shane010330-Jun-24 18:07 
GeneralRe: Dynamic SQL Pin
raddevus1-Jul-24 2:11
mvaraddevus1-Jul-24 2:11 
GeneralRe: Dynamic SQL Pin
Daniel Pfeffer30-Jun-24 19:17
professionalDaniel Pfeffer30-Jun-24 19:17 
GeneralRe: Dynamic SQL Pin
Richard Deeming30-Jun-24 21:31
mveRichard Deeming30-Jun-24 21:31 
GeneralRe: Dynamic SQL Pin
Pete O'Hanlon30-Jun-24 21:45
mvePete O'Hanlon30-Jun-24 21:45 
GeneralRe: Dynamic SQL Pin
jochance2-Jul-24 7:14
jochance2-Jul-24 7:14 
GeneralRe: Dynamic SQL Pin
Sander Rossel9-Jul-24 1:05
professionalSander Rossel9-Jul-24 1:05 
GeneralHow, VS Code? This is amazing. Pin
honey the codewitch22-Jun-24 14:51
mvahoney the codewitch22-Jun-24 14:51 
GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:32
professionalRichard Andrew x6423-Jun-24 4:32 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:35
mvahoney the codewitch23-Jun-24 4:35 
GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:45
professionalRichard Andrew x6423-Jun-24 4:45 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:46
mvahoney the codewitch23-Jun-24 4:46 
GeneralRe: How, VS Code? This is amazing. Pin
Dave Kreskowiak23-Jun-24 6:11
mveDave Kreskowiak23-Jun-24 6:11 
GeneralRe: How, VS Code? This is amazing. Pin
Luschan25-Aug-24 19:32
Luschan25-Aug-24 19:32 

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.