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

 
GeneralWeird, and definitely not wonderful Pin
Marc Clifton18-Feb-15 8:14
mvaMarc Clifton18-Feb-15 8:14 
GeneralRe: Weird, and definitely not wonderful Pin
Sander Rossel18-Feb-15 8:27
professionalSander Rossel18-Feb-15 8:27 
GeneralRe: Weird, and definitely not wonderful Pin
Marc Clifton18-Feb-15 8:41
mvaMarc Clifton18-Feb-15 8:41 
GeneralRe: Weird, and definitely not wonderful Pin
Sander Rossel18-Feb-15 8:50
professionalSander Rossel18-Feb-15 8:50 
GeneralRe: Weird, and definitely not wonderful Pin
manchanx18-Feb-15 8:33
professionalmanchanx18-Feb-15 8:33 
GeneralRe: Weird, and definitely not wonderful Pin
Marc Clifton18-Feb-15 8:43
mvaMarc Clifton18-Feb-15 8:43 
GeneralRe: Weird, and definitely not wonderful Pin
PIEBALDconsult18-Feb-15 9:04
mvePIEBALDconsult18-Feb-15 9:04 
GeneralRe: Weird, and definitely not wonderful Pin
Eddy Vluggen18-Feb-15 9:43
professionalEddy Vluggen18-Feb-15 9:43 
I'd like to propose a simple extra switch to test Sanders code, while still be able to switch back to the old one.
SQL
if (select COUNT(*) from tblSettings where 'test' = 'true') = 0
begin
  if LEN(@accountnumber) >= 4
  begin
    select * from dbo.Departments where accountnumber = @accountnumber order by deptname;
  end
  else
  begin			
    select * from dbo.departments where catid = @catid order by deptname;
  end
end
else
begin
select *
  from dbo.Departments
  where (accountnumber = @accountnumber and LEN(@accountnumber) >= 4)
     or catid = @catid
  order by deptname
end;
You should replace the "4" with a value that you get from a settings-table ofcourse. You don't want to recompile your sproc simply because the length of catids' change. Better yet, replace it with the MIN(LEN(accountnumber)).
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: Weird, and definitely not wonderful Pin
robocodeboy23-Feb-15 4:12
robocodeboy23-Feb-15 4:12 
Rantmmmm Salty passwords PinPopular
Rahul Rajat Singh16-Feb-15 23:46
professionalRahul Rajat Singh16-Feb-15 23:46 
GeneralRe: mmmm Salty passwords Pin
Sander Rossel18-Feb-15 8:28
professionalSander Rossel18-Feb-15 8:28 
GeneralRe: mmmm Salty passwords Pin
Eddy Vluggen18-Feb-15 10:04
professionalEddy Vluggen18-Feb-15 10:04 
GeneralSecurity through, er, idiocy? PinPopular
Rob Grainger11-Feb-15 23:23
Rob Grainger11-Feb-15 23:23 
GeneralRe: Security through, er, idiocy? Pin
User 1013254612-Feb-15 0:31
User 1013254612-Feb-15 0:31 
GeneralRe: Security through, er, idiocy? Pin
newton.saber12-Feb-15 1:24
newton.saber12-Feb-15 1:24 
GeneralRe: Security through, er, idiocy? Pin
_Maxxx_21-Mar-15 17:26
professional_Maxxx_21-Mar-15 17:26 
GeneralRe: Security through, er, idiocy? Pin
ZurdoDev12-Feb-15 1:49
professionalZurdoDev12-Feb-15 1:49 
GeneralRe: Security through, er, idiocy? Pin
kmoorevs12-Feb-15 4:42
kmoorevs12-Feb-15 4:42 
GeneralRe: Security through, er, idiocy? Pin
Sander Rossel13-Feb-15 9:45
professionalSander Rossel13-Feb-15 9:45 
GeneralRe: Security through, er, idiocy? Pin
Rob Grainger13-Feb-15 23:04
Rob Grainger13-Feb-15 23:04 
GeneralRe: Security through, er, idiocy? Pin
Sander Rossel13-Feb-15 23:26
professionalSander Rossel13-Feb-15 23:26 
GeneralResharper not as Sharp as Usual Pin
Rob Grainger9-Feb-15 23:10
Rob Grainger9-Feb-15 23:10 
JokeRe: Resharper not as Sharp as Usual Pin
Kornfeld Eliyahu Peter9-Feb-15 23:19
professionalKornfeld Eliyahu Peter9-Feb-15 23:19 
GeneralRe: Resharper not as Sharp as Usual Pin
User 101325469-Feb-15 23:34
User 101325469-Feb-15 23:34 
GeneralRe: Resharper not as Sharp as Usual Pin
Rob Grainger11-Feb-15 23:21
Rob Grainger11-Feb-15 23: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.