Click here to Skip to main content
15,905,682 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.

 
GeneralFound this a few minutes ago Pin
SomeGuyThatIsMe26-Mar-13 10:51
SomeGuyThatIsMe26-Mar-13 10:51 
Found this in a sp, not sure why it was done this way, @fileLength and @userId are passed in, and i've changed the names of the tables so i could post this, so i realize the tables may not make sense(they do in the real code).

SQL
DECLARE file_Cursor CURSOR FOR SELECT Length
                                 FROM Files f
                                INNER JOIN User p
                                   ON p.UserId    = f.UserId
                                INNER JOIN Playlist pm
                                   ON pm.ListId = p.DefaultListId
                                WHERE p.UserId  = @userId
                                  AND pm.FileNumber <> -1

-- get total length
 OPEN file_Cursor 
FETCH NEXT FROM file_Cursor INTO @length
       
   WHILE @@FETCH_STATUS = 0
   BEGIN                                           
        SET @fileLength = @fileLength + @length   
                            
        FETCH NEXT FROM file_Cursor INTO @length
   END
             
CLOSE file_Cursor 
DEALLOCATE file_Cursor 

Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

GeneralRe: Found this a few minutes ago Pin
Jan Steyn28-Mar-13 0:56
Jan Steyn28-Mar-13 0:56 
GeneralRe: Found this a few minutes ago Pin
SomeGuyThatIsMe28-Mar-13 3:34
SomeGuyThatIsMe28-Mar-13 3:34 
GeneralRe: Found this a few minutes ago Pin
agolddog29-Mar-13 3:39
agolddog29-Mar-13 3:39 
GeneralRe: Found this a few minutes ago Pin
Leng Vang29-Mar-13 6:35
Leng Vang29-Mar-13 6:35 
GeneralRe: Found this a few minutes ago Pin
jschell29-Mar-13 10:43
jschell29-Mar-13 10:43 
GeneralRe: Found this a few minutes ago Pin
SomeGuyThatIsMe1-Apr-13 2:16
SomeGuyThatIsMe1-Apr-13 2:16 
GeneralRe: Found this a few minutes ago Pin
jschell1-Apr-13 8:08
jschell1-Apr-13 8:08 
GeneralRe: Found this a few minutes ago Pin
StatementTerminator1-Apr-13 9:58
StatementTerminator1-Apr-13 9:58 
GeneralFor your next job interview PinPopular
Gary Wheeler15-Mar-13 1:02
Gary Wheeler15-Mar-13 1:02 
GeneralRe: For your next job interview Pin
Pranit Kothari15-Mar-13 1:22
Pranit Kothari15-Mar-13 1:22 
GeneralRe: For your next job interview Pin
Gary Wheeler15-Mar-13 1:26
Gary Wheeler15-Mar-13 1:26 
GeneralRe: For your next job interview Pin
Pete O'Hanlon15-Mar-13 1:34
mvePete O'Hanlon15-Mar-13 1:34 
GeneralRe: For your next job interview Pin
Gary Wheeler15-Mar-13 1:44
Gary Wheeler15-Mar-13 1:44 
GeneralRe: For your next job interview Pin
Marco Bertschi15-Mar-13 2:10
protectorMarco Bertschi15-Mar-13 2:10 
GeneralRe: For your next job interview Pin
Gary Wheeler15-Mar-13 2:19
Gary Wheeler15-Mar-13 2:19 
GeneralRe: For your next job interview Pin
SoMad28-Mar-13 22:54
professionalSoMad28-Mar-13 22:54 
GeneralRe: For your next job interview Pin
Marco Bertschi15-Mar-13 2:19
protectorMarco Bertschi15-Mar-13 2:19 
GeneralRe: For your next job interview Pin
ZurdoDev20-Mar-13 2:52
professionalZurdoDev20-Mar-13 2:52 
GeneralRe: For your next job interview Pin
Gary Wheeler20-Mar-13 2:56
Gary Wheeler20-Mar-13 2:56 
GeneralRe: For your next job interview Pin
ZurdoDev20-Mar-13 3:05
professionalZurdoDev20-Mar-13 3:05 
GeneralRe: For your next job interview Pin
_Maxxx_28-Mar-13 22:22
professional_Maxxx_28-Mar-13 22:22 
GeneralRe: For your next job interview Pin
Gary Wheeler29-Mar-13 2:25
Gary Wheeler29-Mar-13 2:25 
GeneralRe: For your next job interview Pin
CHill6025-Mar-13 5:08
mveCHill6025-Mar-13 5:08 
GeneralShiva Lingam Pin
Prasad Khandekar13-Mar-13 0:26
professionalPrasad Khandekar13-Mar-13 0:26 

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.