Chris
Chris

Reputation: 29

I needed to convert a null to a character string, and i need it to say current employee instead of null

The current code is posted below, is there a way to add in a coalesce to the convert or something? or is there something i can put in the 'null' spot as a style that will change the null return to current employee?

/*------------------------
SELECT PeopleID
    , HireDate
    , CONVERT ( char  ( 20 )  , termdate  , null  ) as [current]
from WORKERS
------------------------*/
PeopleID    HireDate   current
----------- ---------- --------------------
1003        2011-12-10 NULL
1005        2010-10-15 NULL
1007        2011-01-25 NULL
1009        2012-05-24 NULL
1016        2010-06-22 NULL
1021        2011-11-04 NULL
1029        2010-02-10 NULL
1035        2011-05-05 NULL
1040        2010-01-15 NULL
1045        2013-05-01 NULL
1047        2012-08-22 NULL
1055        2012-08-22 NULL
1060        2009-01-25 NULL
1066        2010-06-22 NULL
1073        2014-03-04 NULL
1079        2014-02-04 NULL
2010        2010-06-22 NULL
2014        2010-04-01 NULL

(18 row(s) affected)

Upvotes: 0

Views: 39

Answers (1)

Giorgos Betsos
Giorgos Betsos

Reputation: 72195

Try this:

COALESCE(CONVERT(char(20), termdate), 'Current Employee') AS [current]

Upvotes: 3

Related Questions