October 27, 2006 at 11:55 am
Good Morning all and Happy Friday.
I have this SQL that I need to convert an Integer to a literal string if the value is NULL, otherwise it needs to just be left alone. Here is the SQL that I'm playing with that of course isn't working. The "deleteflag" logic is fine, the "Intgertest" not so much.
Thanks for your help
William
----------------------- SLQ -------------------
select
userid,
category,
payperiod,
case
when
deleteflag IS NULL then 'literal null'
else
deleteflag
end as delflag,
case when
Integertest IS NULL then 'null integer'
else
Integertest
end as IntTest
from timeworked_temp
October 27, 2006 at 12:11 pm
October 27, 2006 at 12:17 pm
Why not do it on the client application? Would cost much cpu cycles on the server (no cast at al to do).
October 27, 2006 at 6:03 pm
As CK suggested... but different...
SELECT UserID,
Category,
PayPeriod,
ISNULL(CAST(DeleteFlag AS VARCHAR(12)),'Literal Null') AS DelFlag
ISNULL(CAST(IntegerTest AS VARCHAR(12)),'Null Integer') AS IntTest
FROM TimeWorked_Temp
--Jeff Moden
Change is inevitable... Change for the better is not.
October 28, 2006 at 8:01 pm
Jeff, would such solution be acceptable if it would be FOR YOU?
_____________
Code for TallyGenerator
October 29, 2006 at 6:44 pm
Only if I absolutely had to put up with the same cruddy requirement that William has obviously been blessed with. It's simple data manipulation that need not be relegated to the rigors of the app.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 29, 2006 at 7:08 pm
Do you think requirements grow on trees?
Who, on you opinion, made this requirement?
_____________
Code for TallyGenerator
October 29, 2006 at 7:46 pm
I think that someone was barking up the wrong tree when they wrote the requirement ... but, since some folks suggested doing it in the app, I thought I'd provide the solution in SQL. Not sure who came up with the requirement and I sometimes get tired of asking on the forum...
Now, where I work is a totally different story... I'd hunt down the person that made such a requirement and shoot them butt first out of a cannon into a stone wall for being so stupid.
William, if you're watching this, please don't take personal offense to this.... I'm thinking that you are NOT the one who wrote the requirement. If you are, beware of stone walls
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply