Click here to Skip to main content
16,010,022 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: Checking for empty guid Pin
Nagy Vilmos27-Jun-14 1:59
professionalNagy Vilmos27-Jun-14 1:59 
GeneralRe: Checking for empty guid Pin
Richard Deeming27-Jun-14 2:36
mveRichard Deeming27-Jun-14 2:36 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 3:11
mvePIEBALDconsult27-Jun-14 3:11 
GeneralRe: Checking for empty guid Pin
Richard Deeming27-Jun-14 3:21
mveRichard Deeming27-Jun-14 3:21 
GeneralRe: Checking for empty guid Pin
PIEBALDconsult27-Jun-14 4:26
mvePIEBALDconsult27-Jun-14 4:26 
GeneralInteresting... Pin
Dave Kreskowiak23-Jun-14 2:53
mveDave Kreskowiak23-Jun-14 2:53 
GeneralRe: Interesting... PinPopular
Simon Lee Shugar23-Jun-14 3:10
Simon Lee Shugar23-Jun-14 3:10 
GeneralRe: Interesting... Pin
0bx23-Jun-14 6:42
0bx23-Jun-14 6:42 
GeneralRe: Interesting... Pin
Bernhard Hiller23-Jun-14 22:37
Bernhard Hiller23-Jun-14 22:37 
GeneralRe: Interesting... Pin
Shameel30-Jun-14 23:48
professionalShameel30-Jun-14 23:48 
GeneralRe: Interesting... Pin
Richard Deeming23-Jun-14 11:26
mveRichard Deeming23-Jun-14 11:26 
GeneralRe: Interesting... Pin
musefan24-Jun-14 4:32
musefan24-Jun-14 4:32 
GeneralRe: Interesting... Pin
Dave Kreskowiak24-Jun-14 4:50
mveDave Kreskowiak24-Jun-14 4:50 
GeneralRe: Interesting... Pin
musefan25-Jun-14 4:39
musefan25-Jun-14 4:39 
GeneralRe: Interesting... Pin
BillW3326-Jun-14 10:41
professionalBillW3326-Jun-14 10:41 
GeneralRe: Interesting... Pin
Brisingr Aerowing30-Jun-14 17:41
professionalBrisingr Aerowing30-Jun-14 17:41 
GeneralRe: Interesting... Pin
Marc Koutzarov29-Aug-14 22:09
professionalMarc Koutzarov29-Aug-14 22:09 
GeneralNot the best example in the book Pin
BotCar22-Jun-14 21:18
BotCar22-Jun-14 21:18 
GeneralRe: Not the best example in the book Pin
Peter_in_278023-Jun-14 16:49
professionalPeter_in_278023-Jun-14 16:49 
GeneralRe: Not the best example in the book Pin
BotCar23-Jun-14 19:26
BotCar23-Jun-14 19:26 
GeneralRe: Not the best example in the book Pin
Kornfeld Eliyahu Peter23-Jun-14 20:56
professionalKornfeld Eliyahu Peter23-Jun-14 20:56 
GeneralRe: Not the best example in the book Pin
BobJanova23-Jun-14 22:55
BobJanova23-Jun-14 22:55 
GeneralRe: Not the best example in the book Pin
Matthew Dennis12-Jul-14 16:14
sysadminMatthew Dennis12-Jul-14 16:14 
GeneralFacePalm Pin
_Maxxx_22-Jun-14 20:43
professional_Maxxx_22-Jun-14 20:43 
So I have been working on a replicating database.
Trigger on one of the tables being replicated, used to populate the Data Warehouse.
So, trigger writes record to 'Ids that need to be updated in the DW' table and calls SP that reads through that table for all unprocessed records, and processes them.

Because some related data may not (yet) have been replicated, this SP can legitimately fail to update the DW, and so shouldn't update the 'Ids that need to be updated in the DW' table to set it as processed.

I"d been having a few problems with various bits and bobs, and had created a table, MaxxxsTemporaryTable, just used for logging stuff.

So here was my code

...
SQL
Insert into DW.SomeTable
Select col, othercol, morecols
From ReplicatedDatabaseTable join AllSortsOfOtherTables

Insert into MaxxxsTemporaryTable Select @Id, @OtherId, @@ROWCOUNT

IF @@RowCount > 0
BEGIN
    Update 'Ids that need to be updated in the DW' table
    Set IsProcessed = 1
    Where Id = @Id
END


But, for some reason, the IsProcessed flag was always being set, even though I knew it was zero, because that was what was written in my temp table!!

Blush | :O I had to post about it to bluff my shame!
PooperPig - Coming Soon

QuestionRe: FacePalm Pin
Brisingr Aerowing30-Jun-14 17:43
professionalBrisingr Aerowing30-Jun-14 17:43 

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.