Click here to Skip to main content
15,886,963 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: 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 
AnswerRe: FacePalm Pin
_Maxxx_30-Jun-14 18:48
professional_Maxxx_30-Jun-14 18:48 
GeneralRe: FacePalm Pin
Brisingr Aerowing30-Jun-14 19:04
professionalBrisingr Aerowing30-Jun-14 19:04 
GeneralI had a cup of coffee today Pin
Munchies_Matt21-Jun-14 22:13
Munchies_Matt21-Jun-14 22:13 
GeneralRe: I had a cup of coffee today Pin
Kornfeld Eliyahu Peter22-Jun-14 0:04
professionalKornfeld Eliyahu Peter22-Jun-14 0:04 
GeneralRe: I had a cup of coffee today Pin
Adam R Harris26-Jun-14 8:40
Adam R Harris26-Jun-14 8:40 
GeneralWhen I say I am going to do a thing... Pin
Dalek Dave18-Jun-14 8:01
professionalDalek Dave18-Jun-14 8:01 
GeneralRe: When I say I am going to do a thing... Pin
OriginalGriff18-Jun-14 8:41
mveOriginalGriff18-Jun-14 8:41 
GeneralRe: When I say I am going to do a thing... Pin
Kornfeld Eliyahu Peter18-Jun-14 8:50
professionalKornfeld Eliyahu Peter18-Jun-14 8:50 
GeneralRe: When I say I am going to do a thing... Pin
OriginalGriff18-Jun-14 8:58
mveOriginalGriff18-Jun-14 8:58 
GeneralRe: When I say I am going to do a thing... Pin
Jörgen Andersson18-Jun-14 20:37
professionalJörgen Andersson18-Jun-14 20:37 
GeneralRe: When I say I am going to do a thing... Pin
Nagy Vilmos18-Jun-14 21:36
professionalNagy Vilmos18-Jun-14 21:36 
GeneralRe: When I say I am going to do a thing... Pin
Richard Deeming19-Jun-14 1:30
mveRichard Deeming19-Jun-14 1:30 
GeneralRe: When I say I am going to do a thing... Pin
cpkilekofp19-Jun-14 7:25
cpkilekofp19-Jun-14 7:25 
GeneralRe: When I say I am going to do a thing... Pin
Bernhard Hiller19-Jun-14 22:32
Bernhard Hiller19-Jun-14 22:32 
GeneralInteresting boolean technique PinPopular
Dan Neely16-Jun-14 8:08
Dan Neely16-Jun-14 8:08 
GeneralRe: Interesting boolean technique Pin
Marc Clifton16-Jun-14 8:14
mvaMarc Clifton16-Jun-14 8:14 

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.