|
Post by Rainbow Rage on Aug 3, 2009 13:28:43 GMT -5
Why?
Why the fuck.
Why the fuck does SQL Server NOT have DECODE?
Seriously.
DECODE(SOURCE, 'P', 'Paper, 'C', 'Carrier', 'D', 'Debit', 'W', 'Web')
EASY
CASE SOURCE WHEN 'C' THEN 'Carrier' ELSE CASE SOURCE WHEN 'D' THEN 'Debit' ELSE CASE SOURCE WHEN 'P' THEN 'Paper' ELSE CASE SOURCE WHEN 'W' THEN 'Web' ELSE SOURCE END END END END as 'Source'
ANNOYING.
/endrant
|
|
|
Post by facm on Aug 3, 2009 19:19:25 GMT -5
Why not just name the database columns what you want to name them as?Hurr, my reading comprehension is gud. This is the way MSDN shows it being used, rather than nesting several loops: msdn.microsoft.com/en-us/library/ms181765.aspxSo, could your statement be: CASE SOURCE WHEN 'C' THEN 'Carrier' WHEN 'D' THEN 'Debit' WHEN 'P' THEN 'Paper' WHEN 'W' THEN 'Web' ELSE 'Null' as 'Source' ? Also, why not just store the actual value you want, rather than translating them later? Right, not the DBA
|
|
|
Post by Rainbow Rage on Aug 3, 2009 19:26:26 GMT -5
Why not just name the database columns what you want to name them as? 'cause I'm not the DBA. >( Source is either D, C, W or P. So you select count on the column, not the most efficient way, but it prevents them from making another table, which is what I would have done >_>
|
|
|
Post by facm on Aug 3, 2009 19:31:00 GMT -5
Edited my post after rereading your original.
|
|
|
Post by Rainbow Rage on Aug 3, 2009 20:53:48 GMT -5
Ya, I'm gonna do what you suggested tomorrow.
Still, that decode statement is easy-mode.
|
|
|
Post by Rainbow Rage on Nov 3, 2009 9:56:04 GMT -5
IF !(NotActive = False) THEN
FACEPALM
|
|